WordCount performance

Walter Bright newshound1 at digitalmars.com
Fri Mar 28 15:47:54 PDT 2008


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.



More information about the Digitalmars-d mailing list