javamultithreadingclojureslimeswank

Killing Infinite Loops in Java/Clojure


Responses to some "potential answers"

Question:

As I get more familiar with Java/Clojure/Swank and incremental code development. I find it very easy for me to accidentally write a clojure function that ends up being an infinite loop -- and run it. This then goes ahead, and pegs the JVM, causing the fans on my laptop to spin up -- and basically, I have to kill the entire JVM to just get rid of one run away thread.

Now, is there anyway I can somehow kill these clojure threads safely? I am well aware that Thread.stop has various unsafe consequences (like holding locks that other threads may need, etc ...) -- however, these here are clojure functions that are infinite looping -- and I'm doing them outside of any STM -- so I'm wondering if there's some way to kill these threads safely.

Thanks!


Solution

  • I don't think a fully complete answer exists, though there are some incomplete but still useful things to do: