(defn add [a b]
(Thread/sleep 300)
(+ a b))
;; Thread. takes any function of no arguments and runs it aside
(def worker
(Thread. (fn [] (println "result:" (add 3 5)))))
(.start worker)
(println "main thread")
;; the answer arrives while the main thread has already moved on;
;; join only holds the exit open long enough to see it printed
(.join worker)
;; output:
;; main thread
;; result: 8