How to find where a thread was originally started How to find where a thread was originally started multithreading multithreading

How to find where a thread was originally started


I would set a breakpoint at Thread.start() and enable a condition

enter image description here

Whenever a thread named "async task" is started the condition is evaluated to true and the thread that invokes the start method is paused. Then you can see in the stacktrace from where the call came.


Had a similar problem in production and wrote a litte java agent that logs the stack of every thread start. So the system can run and you get the info live in the log. That helps a lot, when you have many threads. https://github.com/xdev-software/thread-origin-agent


You can't check whether new thread start or not by using debuger since debug will hang your entire JVM.

You can put some logs and check how threads works there.