Hi guys: The documentation for the clojure atom says that -
"Changes to atoms are always free of race conditions."
However, the condition of the race is determined not only from the point of view of change, but, rather, in the context of parallel logical operations in different threads.
I wonder - what is the significance of the guarantee that "Changes in atoms are always free from race conditions"? In java, we have atomic primitives that support certain thread-safe operations that are specific (e.g. AtomicInteger supports the getAndIncrement operation). But clojure atoms are agnostic types, for example, we can call:
(atom "Hi im a string") Or (atom (.getClass Object))
The flexibility of the atomic method means that Clojure, under the hood, does not “intelligently” provide atomic / thread-safe operations for atoms.
Thus, I would ask - what exactly does the atomic method "do" for our objects (i.e. does it just synchronize the entire object?)
jayunit100
source share