1
當我啓動使用多線程的Android應用程序(它們可以工作並運行)時,我在Android設備監視器中看到的所有內容都是11個線程,絕不會少於我的應用程序。爲什麼Android設備監視器不顯示我的線程?
它們被命名爲main,GC,Signal Catcher,JDWP,Compiler,ReferenceQueueDaemon,FinalizerDaemon,FinalizerWatchdogDaemon,Binder_1,Binder_2,Thread-6542。
應該有幾十個我自己的線程在列表中。看起來好像我的線程只是打包在單個線程上,每個線程運行一段時間並重復。
for (Move m : moves) {
MinMaxThread thread = new MinMaxThread(m, values, color);
thread.run();
threads.add(thread);
}
for (Thread t : threads) {
boolean working = true;
while (working) {
try {
t.join();
working = false;
} catch (InterruptedException e) {
}
}
}
編輯:原來我用的run(),而不是開始()因爲某些原因。
@DamianKozlak這是OP爲解決自己的問題所做的,所以它可能不是「不是答案」。當然,這是一個非常簡短的答案,但問題很簡單。 –