store/[org.clojure/clojure "1.8.0"] clj::clojure.core/locking

Official Documentation

Add notes
Arities
==================================================
   [x & body]

Docstring
==================================================
  Executes exprs in an implicit do, while holding the monitor of x.
  Will release the monitor of x in all circumstances.

Source

(defmacro locking
  "Executes exprs in an implicit do, while holding the monitor of x.
  Will release the monitor of x in all circumstances."
  {:added "1.0"}
  [x & body]
  `(let [lockee# ~x]
     (try
      (monitor-enter lockee#)
      ~@body
      (finally
       (monitor-exit lockee#)))))

Example 1

Edit
(def o (Object.))

(future (locking o 
          (Thread/sleep 10000) 
          (println "done")))

(future (locking o 
          (Thread/sleep 10000) 
          (println "done")))

;; Operates like the synchronized keyword in Java. Because only one of the two
;; threads can have the lock on o at once, and each takes 10s to sleep and print
;; while holding the lock, this program will evaluate in 20s, printing "done" at
;; two 10s intervals.

Uses on crossclj