Recap

STM is a very powerful model for concurrency with quite a few benefits:

  • Provides maximum concurrency dictated directly by real application behavior; that is, instead of an overly conservative, predefined synchronization, we let STM dynamically handle contention.

  • Provides explicit lock-free programming model with good thread safety and high concurrent performance.

  • Ensures identities are changed only within transactions.

  • The lack of explicit locks means we don’t have to worry about lock order and related problems.

  • No explicit locks leads to deadlock-free concurrency.

  • Mitigates the need for up-front design decisions as to who locks and what; instead, we rely on dynamic implicit lock composition.

  • The model is suitable for concurrent reads and ...

Get Programming Concurrency on the JVM now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.