I implemented a JMX method which interrupt / stop a thread and it works in a quite of the cases.
The most important exception is when a thread stuck doing JDBC call and is busy in socketRead0.
We have a job component which is handling a message and finally execute an SQL statement.
Depends on the input this SQL statement could take significiantly long time. Sometimes it is long for a good reason, sometimes it is not. Therefore setting a timeout upfront is not possible.
When it is considered unreasonably long, then technical admin could decide to stop this thread via JMX without restarting the whole application.
The issue is that Thread.interrupt / stop has no effect when the thread is here:
Does oracle JDBC driver have something to pop out the thread from the socketRead0 besides the timeout?