↧
Answer by spongebob for double check locking without volatile (but with...
Yes, this is correct, and it is present on Wikipedia. (It doesn't matter that the field is volatile, since it is only ever accessed from VarHandle.)If the first read sees a stale value, it enters the...
View ArticleAnswer by Eugene for double check locking without volatile (but with...
I am going to try and answer this myself... TL;DR : This is a correct implementation, but potentially more expensive than the one with volatile?.Though this looks better, it can under-perform in some...
View Articledouble check locking without volatile (but with VarHandle release/acquire)
The question is rather easy, in a way. Suppose I have this class:static class Singleton {}And I want to provide a singleton factory for it. I can do the (probably) obvious. I am not going to mention...
View Article