When a worker
thread is hung in a synchronous IO operation (such as a
JDBC call) here is a trick I developed on how to kill the worker thread as well as the supervisory thread.
You may say "but this is brute force, not very elegant!"
Well, at least this brute solution works!
Try using interrupt() or stop() (deprecated, by the way). The worker thread does not respond at all...
So this is the only solution I found.
Enjoy!
/**
* Start thread
*/
public void run () {
cat.debug(Thread.currentThread().getName() + " thread started.");
if (Thread.currentThread().getName().equalsIgnoreCase("SUPERVISOR")) {
try {
Thread.currentThread().sleep(10000);
} catch (InterruptedException e) {}
//Supervisor wokeup
if (queryInProgress) {
stopProcessing = true;
cat.debug(worker.thread.getName() + " will be aborted by supervisory monitor. Query exceeded threshold.");
Runtime.getRuntime().exit(1);
}
}
else {
//Worker thread
worker.sequenceProcessing();
}
}