Clojure STM ( dosync ) x Java synchronize block
What is the difference between Clojure STM (dosync) approach and Java synchronize Block? I'm reading the code below from "The sleeping barber" problem. ( http://www.bestinclass.dk/index.clj/2009/09/scala-vs-clojure-round-2-concurrency.html ) (defn the-shop [a] (print "[k] entering shop" a) (dosync (if (< (count @queue) seats) (alter queue conj a) (print "[s] turning away customer" a)))) To avoid race conditions, dosync is used, so i ask myself "What is the difference (STM) from Java synchronize block" ? Will it block this critical code ? Thanks in advance ! Dantas dosync and synchronized give