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

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

问题描述

在 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 Stacks 上直接执行两个操作:压入和弹出帧.

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天全站免登陆