Object creation (state initialisation) and thread safety

后端 未结 4 1033
你的背包
你的背包 2021-01-24 17:18

I am look into the book \"Java Concurrency in Practice\" and found really hard to believe below quoted statement (But unfortunately it make sense).

http://www.informit.c

4条回答
  •  失恋的感觉
    2021-01-24 17:48

    You misread the book. It explicitely says:

    The problem here is not the Holder class itself, but that the Holder is not properly published.

    So the above construct if fine. What's not fine is to improperly publish such an object to other threads. The book explains that in details.

提交回复
热议问题