Skip to main content

Runtime stack mechanism


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

Popular posts from this blog

Core Java

Content 1 - Language fundamental   Identifier Reserved words Data types Literals Arrays Types of variables Var arg method Main method Java coding standards 2 -  Declaration and Access Modifiers Java source file structure Class modifiers Member modifiers Interfaces 3 - Exception Handling Introduction Runtime stack mechanism Default exception handling in java Exception hierarchy Customized exception handling by try-catch  Control flow in try-catch Methods to print exception information Try with multiple catch blocks Finally Difference between final, finally, finalize Control flow in try-catch-finally Control flow in nested try-catch-finally Various possible combinations of try-catch-finally throw keyword throws keyword Exception handling keywords summary Various possible compile-time errors in exception handling Customized exceptions Top-10 exceptions  4 - String Concept of String Immutable String String Comparison String Conca