线程堆栈的内部 Java 内存模型
The Internal Java Memory Model for Thread Stacks
我正在阅读有关 Internal Java Memory Model 的文章。
有一点想问一下:
Each thread running in the Java virtual machine has its own thread stack. The thread stack contains information about what methods the thread has called to reach the current point of execution.
为什么每个线程都需要保存有关已执行哪些方法的信息(!)?如果它与上下文切换有关,那么(如果我没记错的话)线程必须保存有关当前正在执行的方法的信息。
实际需要保存已执行方法的信息是什么?
这是指当前激活的方法。请注意,线程中可以同时激活多个方法(A 调用 B 调用 C,...)。堆栈不包含有关已完成方法的信息。
我认为改写这一段会使它更清晰、更容易理解:
Each thread running in the Java virtual machine allocates some memory for its call stack. The call stack contains information about what methods the thread has called to reach the current point of execution.
我正在阅读有关 Internal Java Memory Model 的文章。 有一点想问一下:
Each thread running in the Java virtual machine has its own thread stack. The thread stack contains information about what methods the thread has called to reach the current point of execution.
为什么每个线程都需要保存有关已执行哪些方法的信息(!)?如果它与上下文切换有关,那么(如果我没记错的话)线程必须保存有关当前正在执行的方法的信息。 实际需要保存已执行方法的信息是什么?
这是指当前激活的方法。请注意,线程中可以同时激活多个方法(A 调用 B 调用 C,...)。堆栈不包含有关已完成方法的信息。
我认为改写这一段会使它更清晰、更容易理解:
Each thread running in the Java virtual machine allocates some memory for its call stack. The call stack contains information about what methods the thread has called to reach the current point of execution.