使用synchronized、ReentrantLock与CAS自旋方式实现原子操作
示例1:线程不安全的计数器public class AddCountDemo {
private int i = 0;
public static void main(String[] args) {
final AddCountDemo synchronizDemo = new AddCountDemo();
for (int j = 0; j...
原创
2018-04-17 15:04:42 ·
762 阅读 ·
1 评论