grauzone wrote:
I don't understand this. If implemented right (D2.0 or gcc thread variables), TLS can be as fast as a normal global variable. You only need an additional check (a simple if()) to lazily initialize the RNG.

That's the notorious double-checked-locking bug, an incredibly seductive pattern that is wrong and very illustrative about how hard it is to do multithreaded programming correctly.

http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html

Reply via email to