Skip to content

Instantly share code, notes, and snippets.

@loganmhb
Created February 21, 2017 18:36
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 loganmhb/943391292d063dac051f6bc7f1665d89 to your computer and use it in GitHub Desktop.
Save loganmhb/943391292d063dac051f6bc7f1665d89 to your computer and use it in GitHub Desktop.
fun pathological atom situation
(def a (atom 0))
(def f1 (future
(while (< @a 1000000000)
(swap! a inc))
(println "Done incrementing!")))
(def f2 (future
(swap! a (fn [current-val]
(println "Trying...`a' is" current-val)
(Thread/sleep 10) ; actually usually works without this, just from the delay println introduces
0))
(println "Successfully reset!")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment