简体   繁体   English

为什么Android Device Monitor不显示我的线程?

[英]Why Android Device Monitor doesn't show my threads?

When I launch my Android app that uses multiple threads (they do work and run), all I can see in Android Device Monitor is 11 threads, never less, never more, for my application. 当我启动使用多个线程的Android应用程序(它们可以正常工作并运行)时,我在Android Device Monitor中看到的只有11个线程,对于我的应用程序,该线程永远不会少,也不会更多。

They are named main, GC, Signal Catcher, JDWP, Compiler, ReferenceQueueDaemon, FinalizerDaemon, FinalizerWatchdogDaemon, Binder_1, Binder_2, Thread-6542. 它们被命名为main,GC,Signal Catcher,JDWP,Compiler,ReferenceQueueDaemon,FinalizerDaemon,FinalizerWatchdogDaemon,Binder_1,Binder_2,Thread-6542。

There should be dozens of my own threads in that list. 该列表中应该有数十个我自己的线程。 It seems as if my threads are just packed on single thread that runs them for a bit time each and repeats. 似乎我的线程只是打包在单个线程上,每个线程都会运行一段时间并重复执行。

    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) {
            }
        }
    }

EDIT: Turns out I had used run() instead of start() for some reason. 编辑:事实出于某种原因,我使用了run()而不是start()。

使用start()方法启动线程,而不是直接调用run()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM