java - ThreadPoolExecutor clean up when a thread dies -
i have threadpoolexecutor
runs few core , max number of threads. task run creates hornetq (standalone) connections each thread , keeps them alive while thread running. however, cannot close them when thread keepalivetime
expires , thread dies. there way clean resources right before thread dies?
one way out of using pooling solution hornetq connections.
any suggestions highly appreciated.
if using jdk 1.7, embed stuff on closable interface, , closed out of scope. working on implementing on jms 2, meanwhile embed own class delegating stuff. have keep stuff referenced somewhere in thread go out of scope when thread gone. (thread local maybe?)
you need use try (statement=statement.open()) {} , auto closeable called
Comments
Post a Comment