Clojure STM ( dosync ) x Java synchronize block

后端 未结 4 1528
广开言路
广开言路 2021-02-14 05:36

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

4条回答
  •  梦毁少年i
    2021-02-14 05:58

    Just to give a full picture for those seeking, Clojure does have a synchronized analog. It is useful when one has to work with Java non-threadsafe types for interop.

    (locking x & body)
    

提交回复
热议问题