Last active
October 18, 2021 19:07
-
-
Save alysbrooks/c55c2d9c8d0838305f3989982df76c30 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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