How do two or more threads share memory on the heap that they have allocated?

前端 未结 5 572
春和景丽
春和景丽 2020-12-28 08:09

As the title says, how do two or more threads share memory on the heap that they have allocated? I\'ve been thinking about it and I can\'t figure out how they can do it. Her

5条回答
  •  醉话见心
    2020-12-28 08:57

    A really short answer from a bird's view (1000 miles above):
    Threads are execution paths of the same process, and the heap actually belongs to the process (and as a result shared by the threads). Each threads just needs its own stack to function as a separate unit of work.

提交回复
热议问题