go
function returns a channel. You may want to (close! chan)
in shutdown hook.
If you run lein run
you need a main function that will call (run)
to start go thread.
(ns async-demo.core
(:require [clojure.core.async :as async
:refer [<! >! <!! timeout chan alt! go close!]]))
(def ch (atom nil))
(defn run []
(go (while true
(<! (timeout 500))
(prn "inside go"))))
(defn -main [& args]
(println "Starting")
(reset! ch (run))
(.addShutdownHook (Runtime/getRuntime)
(Thread. #(do
(println "SHUTDOWN")
(close! @ch))))
(while true
(<!! @ch)))