Affichage des articles dont le libellé est infinite loops. Afficher tous les articles
Affichage des articles dont le libellé est infinite loops. Afficher tous les articles

mardi 15 juillet 2008

Killing a jvm thread running infinite loop in my app server simply using a Runtime Exception...

One frustrating thing in an application server (moreover in any jvm) is that you have no way to stop a thread going crazy : infinite loops, applicative deadlock...
With the ThreadMXBean API I can even auto detect such troubles logging easily the threads, their stacktraces (no more need for KILL -QUIT, yeahhh...), with ThreadLocal I can add data to get more information about the problem, but still I have no way to act on a thread and "stop it".

I would love to tell the jvm, ok, now the next code to execute on this thread is to raise a kind of RuntimeException... yes I want to say there is a trouble you can't recover from (anyway often it consumes all the cpu... horrible !), so a RuntimeException will correctly rollback all running transactions and correctly release resources. This would save me (and my team) from a server restart which is bad for our users...

Am I the only on to dream of that ? Is it impossible to provide this or nobody thought about it (couldn't find anything about this while googling...) ?