Volatile piggyback. Is this enough for visiblity?

后端 未结 5 873
梦谈多话
梦谈多话 2020-12-05 00:45

This is about volatile piggyback. Purpose: I want to reach a lightweight vars visibilty. Consistency of a_b_c is not important. I have a bunch of vars and I don\'t want to m

5条回答
  •  离开以前
    2020-12-05 01:44

    You don't really have to manually synchronize at all, just use an automatically synchronized data structure, like java.util.concurrent.atomic.AtomicInteger.

    You could alternatively make the sync() method synchronized.

提交回复
热议问题