Created
May 4, 2020 11:16
-
-
Save tggreene/ed7158c9a66ab8eab3e4d5d7c09bbf51 to your computer and use it in GitHub Desktop.
Get a thread by name in clojure
This file contains 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-by-name | |
[thread-name] | |
(let [threads (keys (Thread/getAllStackTraces))] | |
(->> threads | |
(filter #(= thread-name (.getName %))) | |
(some identity)))) | |
;; You can then use the value to stop the thread: | |
(.stop (get-thread-by-name "server-loop")) | |
;; Or just get more information | |
(bean (get-thread-by-name "clojure-agent-send-off-pool-1")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment