Created
February 21, 2017 18:36
-
-
Save loganmhb/943391292d063dac051f6bc7f1665d89 to your computer and use it in GitHub Desktop.
fun pathological atom situation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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