0

我正在开发一个带有一些线程的程序,有时我会收到以下错误消息:

11-03 18:58:06.047: I/dalvikvm(3587): threadid=15: stack overflow on call to      Ljava/lang/ref/FinalizerReference;.<init>:VLL
11-03 18:58:06.047: I/dalvikvm(3587):   method requires 12+20+12=44 bytes, fp is 0x591ad314 (20 left)
11-03 18:58:06.047: I/dalvikvm(3587):   expanding stack end (0x591ad300 to 0x591ad000)
11-03 18:58:06.047: I/dalvikvm(3587): Shrank stack (to 0x591ad300, curFrame is 0x591ad328)

我使用此代码输出我所有的活动线程:

Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]);   
for(int i=0;i<threadArray.length;i++){
    Log.e("Threadtest", threadArray[i].getName()+"|"+ threadArray[i].getClass()+"|"+ threadArray[i].getId());
}

这是输出:

11-03 18:58:02.847: E/Threadtest(3587): Signal Catcher|class java.lang.Thread|205
11-03 18:58:02.847: E/Threadtest(3587): Compiler|class java.lang.Thread|207
11-03 18:58:02.847: E/Threadtest(3587): FinalizerWatchdogDaemon|class java.lang.Thread|210
11-03 18:58:02.847: E/Threadtest(3587): pool-1-thread-1|class java.lang.Thread|217
11-03 18:58:02.847: E/Threadtest(3587): Binder_1|class java.lang.Thread|211
11-03 18:58:02.847: E/Threadtest(3587): ReferenceQueueDaemon|class java.lang.Thread|208
11-03 18:58:02.847: E/Threadtest(3587): Thread-224|class java.lang.Thread|224
11-03 18:58:02.847: E/Threadtest(3587): JDWP|class java.lang.Thread|206
11-03 18:58:02.847: E/Threadtest(3587): main|class java.lang.Thread|1
11-03 18:58:02.847: E/Threadtest(3587): Thread-214|class com.example.evosoft.ComUSB.Send.GCodeSender|214
11-03 18:58:02.847: E/Threadtest(3587): Thread-213|class com.example.evosoft.PrinterInfoSender|213
11-03 18:58:02.847: E/Threadtest(3587): Thread-215|class com.example.evosoft.ComUSB.UsbConnectionChecker|215
11-03 18:58:02.847: E/Threadtest(3587): GC|class java.lang.Thread|204
11-03 18:58:02.847: E/Threadtest(3587): Binder_2|class java.lang.Thread|212
11-03 18:58:02.847: E/Threadtest(3587): FinalizerDaemon|class java.lang.Thread|209

当我知道错误发生在哪个线程时,这将对我有很大帮助。

最好的问候马库斯

4

1 回答 1

0

您是否阅读过有关Android 中线程的基础知识,例如从不从 UI 线程外部与 GUI 交互?

于 2013-11-03T18:27:13.037 回答