http://en.m.wikipedia.org/wiki/Test%5Fand%5FTest-and-set
Instead of simple test and set, loop over test to save expensive memory access.
One should be really careful to avoid double checked locking failure, and this shouldn’t be used in high level language in general.