package com.demo.atomic;
import java.util.concurrent.atomic.AtomicInteger;
public class AtomicDemo {
private static int count = 0;
private static int synchronizedCount = 0;
private static AtomicInteger atomicCount = new AtomicInteger();
public static synchronized void addCount() {
synchronizedCount++;
}
public static void main(String[] args) {
// 创建5个线程
Thread[] threads = new Thread[5];
for (int i = 0; i {
for (int j = 0; j
关注
打赏
Java:原子操作类AtomicInteger代码示例
立即登录/注册


微信扫码登录