Threads and shared data One of the strengths of the Java programming language is its support for multithreading at the language level. Much of this support centers on coordinating access to data shared among multiple threads. 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.
There is only one heap inside the JVM, and all threads share it. The heap contains nothing but objects. Arrays reside on the heap, including arrays of primitive types, but in Java, arrays are objects too. The method area is similar to the stack in that it contains only primitive types and object references. Unlike the stack, however, the class variables in the method area are shared by all threads.