Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SerhiiKozachenko/a1eb1c4a43ecae47c32c072152a66eb6 to your computer and use it in GitHub Desktop.
Save SerhiiKozachenko/a1eb1c4a43ecae47c32c072152a66eb6 to your computer and use it in GitHub Desktop.
(let [f (future
(try
(Thread/sleep 10000)
(catch Throwable e
(println e)
(println "isInterrupted:" (.isInterrupted (Thread/currentThread)))
(println "isAlive:" (.isAlive (Thread/currentThread)))
(println "interrupted:" (Thread/interrupted)))))]
(Thread/sleep 500)
(future-cancel f)
nil)
#error {
:cause sleep interrupted
:via
[{:type java.lang.InterruptedException
:message sleep interrupted
:at [java.lang.Thread sleep Thread.java -2]}]
:trace
[[java.lang.Thread sleep Thread.java -2]
[quantataraxia.core$eval66118$fn__66119 invoke form-init2480698204249510623.clj 3]
[clojure.core$binding_conveyor_fn$fn__5564 invoke core.clj 2022]
[clojure.lang.AFn call AFn.java 18]
[java.util.concurrent.FutureTask run FutureTask.java 264]
[java.util.concurrent.ThreadPoolExecutor runWorker ThreadPoolExecutor.java 1135]
[java.util.concurrent.ThreadPoolExecutor$Worker run ThreadPoolExecutor.java 635]
[java.lang.Thread run Thread.java 844]]}
isInterrupted: false
isAlive: true
interrupted: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment