Heap Memory:
Each time an object is created in Java it goes into the specific memory known as Heap. The member variables of class store in Stack (i.e. Last In First Out) and member variables will store in Heap.
Allocating of Memory in Stack is in run-time when method called it will push to stack and stack pointer increment, stack decremented if method got over.
Heap memory is single memory shared by all thread of JVM whereas each threat contains it own copy of stack memory that’s why Heap is not thread safe and that’s reason we need to handle concurrency issue for Heap memory.
Threads can be executing same method multiple times keeping with its own local variables in his stack memory.