It seems I have an example that shows difference between commute and
alter.
Here it is:
(defn my-inc [x] (dosync (Thread/sleep 1000) (inc x)))
alter***
(def x (ref 0))
(do
(def fut (future (do (Thread/sleep 300) (dosync (alter x inc))
@x)))
(dosync (println @x)(alter x my-inc)(pr
2010/2/18 Аркадий Рост :
> hmm..but in what way I can write code to demonstrate the difference?
You must reproduce the race conditions.
An idea is to start 2 transactions in 2 different threads, while
making the first one sleep sufficiently so you're sure the second one
will commit first.
Simply
hmm..but in what way I can write code to demonstrate the difference?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with
2010/2/18 Аркадий Рост :
> Hi!
> I don't understand difference between commute and alter. In fact I
> don't understand how can I get different results by changing alter to
> commute in code.I've read that the in-transaction value with commute
> is that it may differ from the post-commit value, as t