Skip to content

Instantly share code, notes, and snippets.

@afurmanov
Created August 26, 2019 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afurmanov/2692526007a206537bb1594b4dd876e6 to your computer and use it in GitHub Desktop.
Save afurmanov/2692526007a206537bb1594b4dd876e6 to your computer and use it in GitHub Desktop.
Alternating 1 and 2
(defn -main []
(let [c1 (chan)
c2 (chan)]
(go-loop []
(let [a (<! c1)]
(println a)
(Thread/sleep 1000)
(>! c2 2)
(recur)))
(go-loop []
(let [a (<! c2)]
(println a)
(Thread/sleep 1000)
(>! c1 1)
(recur)))
(>!! c1 1)
(Thread/sleep 10000)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment