I'm told that Clojure has lockless concurrency and that this is Important.
I've used a number of languages but didn't realize they were performing locks behind the scenes.
Why is this an advantage in Clojure (or in any language that has this feature)?
Lockless concurrency also provides the nice advantage that readers never have to wait for other readers. This is especially useful when many threads will be reading data from a single source. You still need to define the data dependencies in your program and explicitly define the parts of a transaction that can be commuted safely.
STM saves you from deadlocks and almost all occurrences of livelock though it does not save you from concurrency failures you can still create cases where a transaction will fail because it lacks the resources to maintain its history but the important part is that concurrency failures will be explicit and you can recover from them
I can't speak about Clojure specifically, but ... it means you don't need to wait for someone to be done with something before you can get to work. Which is great.
Typically it's achieved with immutable types. If nothing can be modified, you don't really need to wait till someone else is done with it before you can access it.
Deadlocks. Or to be more correct the lack of them.
One of the biggest problems in most languages is that you end up with deadlocks that are:
Now with no locks, obviously you won't run into deadlocks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With