Skip to content

Instantly share code, notes, and snippets.

@gasc
Created April 20, 2010 22:09
;simulates heavy asychronous state change
(defn start-frequent-changes [& some-refs]
(let [change (fn [value]
(cond
(pos? value) (inc value)
(neg? value) (dec value)
:else (identity value)))]
(doseq [a-ref some-refs]
(future (loop [] (Thread/sleep 200) (dosync (alter a-ref change)) (recur)))
(Thread/sleep 100))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment