Compare And Swapプログラミングの長所と短所をまとめてくれる人はいますか? (例: マルチコア CPU のパフォーマンス)
Java での例を次に示します。
/**
* Atomically increments by one the current value.
*
* @return the updated value
*/
public final int incrementAndGet() {
for (;;) {
int current = get();
int next = current + 1;
if (compareAndSet(current, next))
return next;
}
}
===編集===
これについては、特にシングル/コア CPU で話してください。