深入理解java虚拟机中有这样一段代码
package AtomicTest;
import java.util.concurrent.atomic.AtomicInteger;
public class AtomicTest {
public static AtomicInteger race = new AtomicInteger(0);
public static void increase() {
race.incrementAndGet();
}
public static final int THREADS_COUNT = 5;
public static void main(String[] args) throws Exception {
Thread[] threads = new Thread[THREADS_COUNT];
for(int i = 0; i < THREADS_COUNT; i++) {
threads[i] = new Thread(new Runnable() {
@Override
public void run() {
for(int i = 0; i < 10000; i++) {
increase();
}
}
});
threads[i].start();
}
while(Thread.activeCount() > 1) {
Thread.yield();
}
System.out.println(race);
}
}
这段代码放到IDEA中会陷入死循环、为什么