Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

miikka/long-thread

Repository files navigation

long-thread 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.

About

Java threads in Clojure

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Packages

Contributors

AltStyle によって変換されたページ (->オリジナル) /