JAVA threads (different stacks) synchronization

后端 未结 8 1602
北恋
北恋 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:58

    Only primitive types, such as int are guaranteed to be allocated on the stack. Objects and arrays are all typically stored in the heap unless Escape Analysis determines the scope of the object is 'restricted to the scope of the procedure'.

提交回复
热议问题