5

Let's assume I have deployed on a JBoss/Tomcat server a stupid service that just makes a Thread.sleep() (or somehow falls into a deadlock situation).

If this service receives enough incoming requests, all http threads eventually get stuck forever, and the server won't be able to process any other request until it is restarted.

Is there any timeout mecanism at JBoss/Tomcat level that would release/kill/recycle a http thread if the request processing is longer than a given delay, so that it can handle new incoming requests?

sdabet
  • 18,360
  • 11
  • 89
  • 158
  • 2
    Related: http://stackoverflow.com/questions/7145131/tomcat-request-timeout – Gimby Nov 10 '15 at 15:08
  • @Gimby Thanks. So basically there's no out-of-the-box solution for that, right? – sdabet Nov 10 '15 at 15:10
  • 1
    Not that I know of, and I have faith in the intelligence of the Tomcat developers; if there is a reliable way to do it, they would have implemented it and documented it. Basically its the same question as "How do you reliably stop a hanging Java thread". http://javaeesupportpatterns.blogspot.nl/2012/01/java-stop-thread-think-again.html – Gimby Nov 10 '15 at 15:16
  • There isn't any safe way to kill a thread in Java from outside the thread, period. If you find you have this problem, the best solution is to modify the code that runs within the thread to time out when appropriate. And this is one of those cases where I really do think this is a duplicate, of the post that Gimby found. – Warren Dew Nov 10 '15 at 17:36

1 Answers1

0

Obviously there is no such built-in mechanism in Tomcat.

And more generally, killing a java thread cannot be done without the thread's cooperation.

sdabet
  • 18,360
  • 11
  • 89
  • 158