Tuesday, January 8, 2013

How the data stored in Java Threads?

The data in java is stored in various places.

In Java Virtual Machine each thread is awarded with a stack which is not allowed to access by other threads.

    • Stack
    • Heap
    • Method Area

Stack : Contains the local variables, parameters and return values of invoked methods for each thread. This stack information cannot be accessed by other threads. The stack also contains the Objects instance variables but not the objects itself.

Heap: The heap contains the objects which shall be shared across all the threads.

Method Area: This contains only the class variables (static variables) which are accessible by all threads.

No comments:

Post a Comment