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.b
basic difference is following
Clojure STM supports optimistic concurrency whereas JAVA synchronized is pessimist
Clojure STM does not acquire lock until there are more than one thread. if mutable state is updated by another thread then the operation inside dosync is repeated. Also, dosync is mandatory for mutable states. Clojure throws illegalState exception when dosync is missing, unlike JAVA.