Runtime stack mechanism: For every thread, JVM will create a separate stack all method calls performed by the thread will be stored in that stack. Each entry in the stack is called “one activation record” (or) “stack frame”. After completing every method call JVM removes the corresponding entry from the stack. After completing all method calls JVM destroys the empty stack and terminates the program normally.
Example:
class Test
{
public static void main(String[] args)
{
doStuff();
}
public static void doStuff()
{
doMoreStuff();
}
public static void doMoreStuff()
{
System.out.println("Hello");
}
}
Output:
Hello
Diagram:
Comments
Post a Comment