Skip to content

Instantly share code, notes, and snippets.

@LauJensen LauJensen/client.clj
Created Oct 14, 2010

Embed
What would you like to do?
(defn with-timeout [thunk]
(let [task (FutureTask. thunk)
thr (Thread. task)]
(try
(.start thr)
(.get task 10 TimeUnit/SECONDS)
(catch TimeoutException e
(.cancel task true)
(.stop thr (Exception. e))
nil))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.