My understanding of transactions is that they don't block each other even when the same refs are involved. Obviously, I'm wrong, see the following scenario:
user=> (def thread (agent "Thread")) #'user/thread user=> (def account (ref 1000)) #'user/account user=> (send thread (fn [agt aref] (dosync (alter aref + 100) (Thread/sleep 8000) agt)) account) #<Agent@11afd9cc: "Thread"> user=> (time (dosync (ref-set account 2000))) "Elapsed time: 6838.605366 msecs" 2000 Trying '(dosync (ref-set account 2000))' while the thread is running blocks the REPL. Interestingly, the threaded transaction isn't retried as a effect of changing the ref-value while the threaded-transaction is still running. My understanding is that the threaded transaction tries to commit *after* Thread/sleep, realizes a changed value for account and retries the transaction. (BTW, if 'alter' is replaced by 'commute', the REPL does not block.) What's really going on behind the scenes? What am I missing? Cheers, Dominikus -- 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 your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en