On 5/19/2013 2:02 PM, Walter Bright wrote:
If you have a global value accessible from multiple threads, you must use
synchronization. There is no way around that. If you use some other global state
to check for initialization in order to avoid synchronization, you have the
double checked locking bug. Yes, you do.


BTW, a few years ago, I presented my clever solution to the double checked locking bug to Scott Meyers. I was very proud of it. Scott handed me my @ss (in a nice way), but I got my comeuppance.

It reminded me of the hours I spent in high school determined to show that I could trisect an angle with a compass and a straightedge. There was always some tiny flaw :-)

Reply via email to