O'Reilly logo

IBM WebSphere eXtreme Scale 6 by Anthony Chaves

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

Deadlocks

We can avoid the OptimisticCollisionException by using the pessimistic lock strategy. The pessimistic strategy assumes that objects can and will be updated simultaneously by multiple threads. By assuming that multiple threads will be writing to objects in a BackingMap, we give up a little concurrency, but we don't need to handle OptimisticCollisionExceptions. Where the optimistic lock strategy only briefly holds S or X locks, the pessimistic strategy holds locks for the duration of the transaction. The pessimistic lock strategy also makes the U lock available for use.

When we use a get method to retrieve an object from a BackingMap, our transaction in thread 1 obtains an S lock on that object and holds it for the duration of 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