Subj : Re: why one stack per thread and one heap for multithread? To : comp.compilers.lcc,comp.programming.threads From : Casper H.S. Dik Date : Fri Feb 25 2005 04:37 pm tonyosborne_a@hotmail.com (TonY) writes: >why in multithreading, each thread has its own stack, but all share >the same heap? >I understand that one stack is needed for each thread as each could >have its own procedure call. but why we don't associate a heap for >each thread since each thread can also create dynamically its own >data? Or better: their own address space .... :-) Heap allocated objects are not private to a thread and often exchanged between threads; so threads will need to free stuff on other thread's heaps and when a thread goes away you can't reclaim its heap. So you have to have the same amount of locking and you get more administrative overhead. Casper -- Expressed in this posting are my opinions. They are in no way related to opinions held by my employer, Sun Microsystems. Statements on Sun products included here are not gospel and may be fiction rather than truth. .