Hi, Am 26.04.2011 um 22:33 schrieb Zlatko Josic:
> Is this scenario posible : > > (def test-map (ref {})) > > (def test-map2 (ref {})) > > (defn process > [map1 map2] > (cond > (and (empty? @map1) (empty? @map2)) > (dosync > ((alter map1 assoc key1 value1) > (alter map2 assoc key2 value2) > ..... > > > Suppose the process method is called from many threads. Is it posible that > one thread tests first condition (empty? @map1) and gets true > than another thread comits its transaction wich puts values in both maps. Now > first thread check second > condition (empty? @map2) which is false. Yes. This is perfectly possible. You have to wrap the whole cond in a dosync. Otherwise it is not guaranteed that you see consistent values of map1 and map2. Sincerely Meikel -- 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