WordCount performance

Benji Smith benji at benjismith.net
Fri Mar 28 23:33:33 PDT 2008


Walter Bright wrote:
> Sean Kelly wrote:
>> Another option might be to check the thread count is greater than
>> 1 and only lock if it is.  Tango has a routine called thread_needLock
>> for this purpose, though it goes a bit farther and is true once a
>> thread has been created through program termination.  This avoids
>> problems with the situation where you have multiple threads running
>> and all but one terminate but memory is not yet synchronized.
> 
> You have to be very careful with such schemes because they can run afoul 
> of the notoriously difficult to comprehend "double checked locking" bug.

I thought the double-checked locking idiom was only buggy in the Java 
memory model (prior to being fixed in the 1.6 JDK).

--benji smith



More information about the Digitalmars-d mailing list