O'Reilly logo

Java 9 Concurrency Cookbook - Second Edition by Javier Fernández González

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

There's more...

You can find a situation where a requirement prevents you from getting the locks in the same order in all the operations. In this situation, you can use the tryLock() method of the Lock class. This method returns a Boolean value to indicate whether you have control of the lock. You can try to get all the locks that you need to do the operation using the tryLock() method. If you can't get control of one of the locks, you must release all the locks that you may have had and start the operation again.

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