Where do I start investigating my Java process that won't end?
You need to do one of two things to terminate your ExecutorService
thread:
- Specify a
ThreadFactory
that creates daemon threads (theThreadFactoryBuilder
class from Guava will make this easier.) - Call
shutdown()
on yourExecutorService
as part of the application shutdown (e.g. at the end of yourmain
method.)
Not sure how large the application is but I would check all the Threads you've created and ensure that their run methods are cleanly exited when the application is done executing. Somewhere, within a thread, you may have code along the lines of:
public void run() { while(true) { //"true" or some condition that never gets a chance to be false //do thread related work }}