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

Commit and Rollback Events

Java’s try-catch-finally facility allows us to handle exceptions and selectively run some code only when there’s an exception. Similarly, we can decide to run a piece of code only if a transaction committed and another piece of code only if a transaction rolled back. These are provided as deferred and compensating methods, respectively, on StmUtils. The deferred method is a great place to perform all the side effects that we were holding off to ensure the transaction completes.

Commit and Rollback Events in Java

We place the code that we want to run when a transaction succeeds in the code block (Runnable) that’s passed to the deferred method of StmUtils. Likewise, we’ll place the code we want to run when the transaction ...

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