J Kommu wrote:Actually I want to know what happens under the hood to a Java method at runtime.
what exactly resides on the heap for a method..?
Ummm... whatever the method puts there? Plus whatever was on the heap before the method was called.
As a minimum: nothing is created on the heap automatically when a method is called. If, within the method, you do something that creates something on the heap (like say "Object obj = new Object();", then that happens. If you don't, it doesn't.
Is it possible you were really wondering about what happens on the stack, and said heap by mistake?
J Kommu wrote:And if this method is concurrently run by multiple threads how does the JVM/ processor handle it. (considering the method is not synchronized.)
Each thread has its own call stack. They share the heap, if they do anything that accesses the heap. But as far as the basic mechanism of calling a method from a thread, each thread stores the information they need to do that (mostly the method parameters and the return address, i.e. what-was-I-doing-when-I-called-this-method, get pushed onto the stack for that thread, when the method is called. And popped off of the stack when the method exits.
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.