A little of coordination for Rosettacode
Stanislav Blinov
stanislav.blinov at gmail.com
Wed Feb 26 04:46:53 PST 2014
I forgot to note that both synchronized {} blocks should also be
synchronizing on the same mutex. Right now it's two different
critical sections, so a race is still possible, i.e. while one
thread is printing the other may be removing the first printer.
Run the code several times and you'll no doubt stumble upon it.
The mutex could be emulated with a shared bool and
std.atomic.cas(). That would get rid of synchronized{} blocks and
would potentionally be faster.
More information about the Digitalmars-d-learn
mailing list