Search code examples
javamultithreadingdebuggingintellij-ideabreakpoints

how to find the place where a Thread was started from a breakpoint


This is my situation:

  • I am studying a large codebase, running on Java1.7, not very easy to move around, lots of interfaces, deep inheritance trees, lots of threads etc.
  • I put a breakpoint in some place, but this object is running in a Thread that was spawned somewhere. I need to find that place.
  • there are too many .run() and .start() hits to look for individually (and to narrow down by the class is difficult too as there are many classes/inheritance (and I don't know the codebase yet)).

So my questions is, is there a way, having a Thread stopped in a breakpoint (intelliJ, but I can use eclipse too) to find out where it was started??

thanks


Solution

  • No.

    I don't think there's a way out of this without some brute force effort.

    I would trace back to the Runnable that was started (through the stack trace), then get that class' inheritance and interface hierarchy, then look for run() and start() methods on all those classes. Unless someone has just gone nuts with inheritance, it shouldn't take that long.