I know that local variables and paramters of methods live in stack, but I not able to figure out where does actually methods live in case of Java?
If I declare any Thread object like:
Thread t=new Thread();
t.start();
So it means I've created a separate calling of methods apart from main method. What does it mean? Does it mean calling of separate sequence of methods over Stack memory? Am I right?
Each thread is allocated its own stack.
This article has a good introduction to the memory separation within a Java process.
Inside the Java virtual machine, each thread is awarded a Java stack, which contains data no other thread can access, including the local variables, parameters, and return values of each method the thread has invoked. The data on the stack is limited to primitive types and object references. In the JVM, it is not possible to place the image of an actual object on the stack. All objects reside on the heap.
I've seen many scenarios where clients have implemented hugely threaded servers on the basis that each thread does very little, and they run into problems with memory. That's because each thread is allocated its own stack, and this (obviously) adds up. I think the default value is 512k per thread, but I've not found a canonical source for that.