Thread.activeCount()運(yùn)行出錯(cuò)問(wèn)題
......
? ? System.out.println(Thread.activeCount());
? ? while (Thread.activeCount() > 1) {
? ? ? Thread.yield();
? ? }
? ? System.out.println(t.getNum());
按照教程中寫的代碼
打印結(jié)果:
877
1000
FATAL ERROR in native method: JDWP cannot get thread local storage, jvmtiError=JVMTI_ERROR_WRONG_PHASE(112)
JDWP exit error JVMTI_ERROR_WRONG_PHASE(112): cannot get thread local storage [../../../src/share/back/threadControl.c:195]
為什么有警告輸出?
2016-01-14
你代碼寫錯(cuò)了哦,while(Thread.activeCount() < 1),是活躍的線程數(shù)量小于1,你寫成大于號(hào)啦