Skip to content

Instantly share code, notes, and snippets.

@afurmanov
Created August 26, 2019 01:28
Show Gist options
  • Save afurmanov/1681142b8466457f3dd67e7637ccb139 to your computer and use it in GitHub Desktop.
Save afurmanov/1681142b8466457f3dd67e7637ccb139 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