A Clojure library for starting and stopping threads. Basically just a wrapper for
java.lang.Thread
.
Clojure has plenty fancy tools such as futures for concurrent programming.
However, sometimes what you need is a good old thread. You could use Java's
Thread
directly, but the purpose of this wrapper is to encourage good
practices such as always naming your threads.
(ns example.core
(:require [long-thread.core :as long-thread]))
(defn my-loop
[]
(long-thread/until-interrupted
(println "This is your regularly scheduled greeting: Hello!")
(Thread/sleep 1000)))
(defn main
[]
(let [my-thread (long-thread/create "greetings thread" my-loop)]
(println "Press enter to stop...")
(read-line)
(long-thread/stop my-thread)))
The inspiration for this work is zthread.clj
, a similar library developed by
Joel Kaasinen and others at ZenRobotics.
lein test
lein cloverage
and look at target/coverage/index.html
.Copyright Miikka Koskinen.
Available under the terms of the Eclipse Public License 2.0, see LICENSES/EPL-2.0.txt
.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close