JAVA threads (different stacks) synchronization

后端 未结 8 1610
北恋
北恋 2021-01-05 22:19

I have a question regarding synchronization of code that is executed by several threads:

As far as I know each thread has its own stack, hence, non-static variables

8条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-05 22:59

    Stack yes (think of a call stack, local variables), but class variables live in the heap and you have to synchronize access to them:)

提交回复
热议问题