脱掉锁的外衣

volatile int i = 0;


void getLock(){
compareAndSet(0,1)
}


void unlock(){
i=0;
}


void run(){
getLock();
doSomeThing();
unlock();
}

猜你喜欢

转载自blog.csdn.net/qq_29857681/article/details/80079018
今日推荐