I\'ve read a lot about how great Clojure is when it comes to concurrency, but none of the tutorials I\'ve read actually explain how to create a thread. Do you just do (.start (T
Usually when I want to start a thread in Clojure I just use future.
As well as being simple to use, this has the advantage that you avoid having to do any messy Java interop to access the underlying Java threading mechanisms.
Example usage:
(future (some-long-running-function))
This will execute the function asynchronously in another thread.
(def a (future (* 10 10)))
If you want to get the result, just dereference the future, e.g:
@a
=> 100
Note that @a will block until the future thread has completed its work.