转:http://www.cnblogs.com/lucifer1982/archive/2009/04/08/1431992.htmlhttp://en.wikipedia.org/wiki/Compare-and-swapIncomputer science,compare-and-swap(CAS) is anatomicinstructionused inmultithreadingto achievesynchronization. It compares the contents of a memory location to a given value and, only if Read More