Skip to content

Instantly share code, notes, and snippets.

@alysbrooks
Last active October 18, 2021 19:07
Show Gist options
  • Save alysbrooks/c55c2d9c8d0838305f3989982df76c30 to your computer and use it in GitHub Desktop.
Save alysbrooks/c55c2d9c8d0838305f3989982df76c30 to your computer and use it in GitHub Desktop.
(defn get-thread-states []
(->> (Thread/getAllStackTraces)
(.keySet)
(into [] )
(mapv #(.getState %))
frequencies))
(defn futures-quit [n ms]
;; Start a bunch of threads
(doseq [_ (range n)]
(future (Thread/sleep ms) (println "Finished")))
(println "Exiting...")
;; Print the statuses of all the threads:
(println (get-thread-states))
(System/exit 1))
(futures-quit 10 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment