Talk:Test and test-and-set

double-checked locking?
I don't see how double-checked locking is an example of this. --Apoc2400 05:43, 16 November 2006 (UTC)
 * It uses the same pattern of simple checking and then checking and doing the work within a critical section. —The preceding unsigned comment was added by 193.172.180.130 (talk) 09:27, 9 May 2007 (UTC).
 * I'm sorry, but I think the unsigned commenter is confused. They do use "the same pattern" in a very broad sense, but it is not this broad pattern that is unsafe.
 * DCLP is indeed unsafe when used together with singleton (which is the classic use case). The reason for this has to do with the way in which it combines assignment and object construction.  Even though it seems like the object construction "should" happen before the pointer assignment, that may not be the order in which the writes become visible to other unsynchronized threads.  Since test-and-set changes a scalar value, there is no reordering risk.
 * The claim that DCLP is an "example of bad usage of this idiom" is, at the very least, not supported by references. --BertD (talk) 18:03, 23 April 2009 (UTC)
 * I'm with Bert. It's almost antithetical, when you get down to this.  Double Checked locking is different in more ways than just that, in that it checks to try and see if locking is needed, rather than trying to make the check for lock-availability cheaper.  They're... I mean, do they have anything in common?  —Preceding unsigned comment added by 12.146.21.163 (talk) 00:30, 4 February 2011 (UTC)