0

In my Java app I'm using ExecutorService to start and shutdown threads, but when the app is done, some threads are still running, so I used Netbeans[8] profiler to see why so I can terminate them, but as you can see from the attached chart, there are lots of them still running and I don't know where in my app these threads started, I double clicked and right clicked on the threads, nothing happened, I guess there must be a way to get to my code from the chart, can someone tell me how ?

enter image description here

Frank
  • 30,590
  • 58
  • 161
  • 244

1 Answers1

1

Many implementations of ExecutorService manage a thread pool. Your instance has several threads in the WAITING state, perhaps as a result of invoking LockSupport.park(). The API illustrates a common shutdown approach, which you can tailor to your use.

Addendum: As a concrete example, this WorkerLatchTest creates a pool of N = 8 worker threads. Double click on a thread in the timeline to see details about the thread.

image

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045