O'Reilly logo

Programming Concurrency on the JVM by Venkat Subramaniam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Transactions

We create transactions to coordinate changes to multiple managed references. The transaction will ensure these changes are atomic; that is, all the managed references are committed or all of them are discarded. Outside the transactions, we’ll never see any partial changes. We also create transactions to coordinate a read followed by a write to a single ref.

Akka was built on Scala, and we can enjoy its concise API if we’re using Scala. For programmers who can’t make that switch, Akka also provides a convenient API to use its features from the Java language. Alternately, we may directly use Multiverse STM from Java. We’ll see how to create transactions using Akka in Java and Scala in this section.

First we need an example ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required