package zhaozi.parallel;import java.util.concurrent.atomic.AtomicInteger;public class AtomicTest {
public static AtomicInteger value = new AtomicInteger(0);
public static int value1 = 0;
public static final int THREAD_COUNT = 20; public static void increase() {
value.incrementAndGet(); } static class MyThread implements Runnable {
public void run() {
for (int i = 0; i < 1000; i++)
increase();
}
} public static void main(String[] args) {
for (int i = 0; i < THREAD_COUNT; i++) {
new Thread(new MyThread()).start(); }
System.out.println(value); }}
结果每次都不确定,不是20000。我的测试用例哪里有问题呢。