Is the != check thread safe?

后端 未结 8 1977
醉酒成梦
醉酒成梦 2021-01-29 18:56

I know that compound operations such as i++ are not thread safe as they involve multiple operations.

But is checking the reference with itself a t

8条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-29 19:20

    Even simple read is not atomic. If a is long and not marked as volatile then on 32-bit JVMs long b = a is not thread-safe.

提交回复
热议问题