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

Concurrency Using STM

Transactions are nice, but what happens if two transactions try to change the same identity? Sorry, I didn’t mean to keep you on the edge of your seat this long. We’ll take a look at a couple of examples of that in this section.

A word of caution, though, before we walk through the examples. In production code, make sure that transactions are idempotent and don’t have any side effects, because they may be retried a number of times. That means no printing to the console, no logging, no sending out emails, and no making any irreversible operations within transactions. If we do any of these, we’re responsible for reversing the operations or dealing with the consequences. In general, it’s better to gather up these side-effect ...

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