3 ms·
> Or to put it another way, why do you think other threads would see the value of stringCache change True, other threads might not see the value of stringCache
by cesarb 9y ago
> Or to put it another way, why do you think other threads would see the value of stringCache change
True, other threads might not see the value of stringCache change. However, if and when they see it change, they will see it change to another valid String. They will never see an incompletely initialized String.
Using AtomicReference or volatile gives you stronger guarantees, but they're not necessary here.