Threads each have their own stack, but they share a common heap.
Its clear to everyone that stack is for local/method variables & heap is for instance/class variables.
What is the benefit of sharing heap among threads.
There are several number of threads running simultaneously, so sharing memory can lead to issues such as concurrent modification, mutual exclusion etc overhead. What contents are shared by threads in heap.
Why is this the case? Why not have each thread own its own heap as well? Can anyone provide a real world example of this, how shared memory is utilized by threads?