Liking cljdoc? Tell your friends :D

long-thread codecov cljdoc badge

A Clojure library for starting and stopping threads. Basically just a wrapper for java.lang.Thread.

Latest version

Clojars Project

Why?

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.

Usage

(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)))

Acknowledgements

The inspiration for this work is zthread.clj, a similar library developed by Joel Kaasinen and others at ZenRobotics.

See also

Development guide

  • Run tests with lein test
  • Generate a test coverage report with lein cloverage and look at target/coverage/index.html.

License

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