Why reading a volatile and writing to a field member is not scalable in Java?

前端 未结 5 463
遇见更好的自我
遇见更好的自我 2021-01-30 22:04

Observe the following program written in Java (complete runnable version follows, but the important part of the program is in the snippet a little bit further below):

         


        
5条回答
  •  佛祖请我去吃肉
    2021-01-30 22:15

    Short: apparently, the answer is false sharing due to card marking for the GC.

    A more extensive explanations is given in this question:

    Array allocation and access on the Java Virtual Machine and memory contention

提交回复
热议问题