“调用堆栈"与“调用堆栈"之间的区别在于:和“线程堆栈" [英] Difference between "call stack" and "thread stack"

查看:166
本文介绍了“调用堆栈"与“调用堆栈"之间的区别在于:和“线程堆栈"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java多线程中,术语call stackthread stack之间是否存在语义差异?

Is there a semantic difference between the terms call stack and thread stack, in Java multithreading?

推荐答案

每个线程都有自己的调用堆栈,调用堆栈"和线程堆栈"是同一回事.将其称为线程堆栈"只是强调调用堆栈是特定于线程的.

Each thread has its own call stack, "call stack" and "thread stack" are the same thing. Calling it a "thread stack" just emphasizes that the call stack is specific to the thread.

Bill Venners将其称为Java堆栈:

启动新线程时,Java虚拟机将为该线程创建一个新的Java堆栈.如前所述,Java堆栈将线程的状态存储在离散的帧中. Java虚拟机仅直接在Java堆栈上执行两项操作:推送和弹出框架.

When a new thread is launched, the Java virtual machine creates a new Java stack for the thread. As mentioned earlier, a Java stack stores a thread's state in discrete frames. The Java virtual machine only performs two operations directly on Java Stacks: it pushes and pops frames.

线程当前正在执行的方法是线程的当前方法.当前方法的堆栈框架是当前框架.定义当前方法的类称为当前类,当前类的常量池为当前常量池.在执行方法时,Java虚拟机将跟踪当前类和当前常量池.当虚拟机遇到对堆栈帧中存储的数据进行操作的指令时,它将在当前帧上执行这些操作.

The method that is currently being executed by a thread is the thread's current method. The stack frame for the current method is the current frame. The class in which the current method is defined is called the current class, and the current class's constant pool is the current constant pool. As it executes a method, the Java virtual machine keeps track of the current class and current constant pool. When the virtual machine encounters instructions that operate on data stored in the stack frame, it performs those operations on the current frame.

当线程调用Java方法时,虚拟机将创建新框架并将其推入线程的Java堆栈.然后,该新帧将成为当前帧.该方法执行时,它使用框架来存储参数,局部变量,中间计算和其他数据.

When a thread invokes a Java method, the virtual machine creates and pushes a new frame onto the thread's Java stack. This new frame then becomes the current frame. As the method executes, it uses the frame to store parameters, local variables, intermediate computations, and other data.

这篇关于“调用堆栈"与“调用堆栈"之间的区别在于:和“线程堆栈"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆