Home » Android » android – Unknown bug "Thread starting during runtime shutdown"

android – Unknown bug "Thread starting during runtime shutdown"

Posted by: admin May 14, 2020 Leave a comment


I’m using Fabric to report crash for my app.
I have received those report for a very long time and the number of crashes keep increasing.

Fatal Exception: java.lang.InternalError: Thread starting during runtime shutdown
   at java.lang.Thread.nativeCreate(Thread.java)
   at java.lang.Thread.start(Thread.java:730)
   at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:941)
   at java.util.concurrent.ThreadPoolExecutor.processWorkerExit(ThreadPoolExecutor.java:1009)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1151)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
   at java.lang.Thread.run(Thread.java:761)

There is also a list of 62 Threads attached with this report, I can post it here if you guys want.

I have no idea which part of code cause this or how to replicate the bug. So I hope you can guide me to find and solve this case.

How to&Answers:

I had the same issue…

I have updated the fabric plugin, then updated the twitter sdk..

then clean my project and rebuild the apk..my error has been gone.

some time this error occurred while some ANR occurs.


The current thread is started too late, that is, when you receive an uncaught exception in the UncaughtExceptionHandler, a child thread is started to upload the error log.
HttpClient is created when the error log is uploaded, but ThreadSafeClientConnManager was set to manage the connection when created.

By viewing the source code of ThreadSafeClientConnManager, it was found that ThreadSafeClientConnManager also opened child threads, which caused the problem of opening child threads in child threads, which would cause uncaughtException () in the thread after execution was completed Only when the thread is started, java.lang.InternalError: Thread starting during runtime shutdown will be thrown.

The solution to this problem is: Create HttpClient in advance, because HttpClient creation will also start the thread, avoid creation in uncaughtException (), thereby avoiding the problem of starting the thread in the thread.

Alternative solution: Remove UncaughtExceptionHandler from your code in case it tried to create a thread.