Finding Source of Thread Creation in a Java application

I am working on a Java application which has a threading issue.

While using the applications for some time with Netbeans profiler attached, I can see several threads are created. Most of them finish in some .5 seconds . I could only find SwingWorkers used in the application.

Moreover, the majority of threads displayed by the profiler are normal threads and not SwingWorkers. Unless these threads were created by SwingWorker indirectly, I suspect, some library that the application uses is creating them.

Now I would like to remove this issue. But I could not find a way to determine the source of thread creation. If you can please suggest some other profiler/tool by means of which I can find the source(method) of thread creation.


If using Eclipse and its debugger is an option, you might try the following:

  • Import the code into a Java project.
  • Ctrl-Shift-T (Open Type), enter "Thread". The binary source editor for the Thread class opens.
  • Select all the Thread constructors in the Outline view, use context menu "Toggle Method Breakpoint". That creates breakpoints for the constructors.
  • Run and debug.
  • Alternatively

    You could get the Yourkit Java profiler, which is also available for evaluation. It can show the threads created in an application including their stack traces (also after the thread finished). It does not show where the threads were created, but the stack trace of the threads might give you some clues about the involved libraries.


    JProfiler can do that. The thread monitor view shows the stack trace where a thread was created - if CPU recording was active at that time:

    在这里输入图像描述

    Disclaimer: My company develops JProfiler

    链接地址: http://www.djcxy.com/p/82422.html

    上一篇: HTML中的退格

    下一篇: 在Java应用程序中查找线程创建源