Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find where a thread was originally started

Supposed I have an application that can spawn multiple threads if needed for doing tasks ... so nothing special. I use Eclipse to write and debug Java applications. A thread (lets call it "async task") is immediatly respawned after it leaves the run() method (so there is bug and I want to find the reason for this behavior).

My question, if I pause this thread "async task" using the eclipse IDE (debug perspective ..) is there way to find out where this thread was originally started (for example using the Debug view or any other)? Because I want to know who spawns this thread (without making a text search or something like this).

Is there a good way to get this information?

like image 468
Michael Dietrich Avatar asked Dec 02 '13 10:12

Michael Dietrich


1 Answers

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.

like image 164
René Link Avatar answered Sep 29 '22 08:09

René Link