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...

The AbstractQueuedSynchronizer class provides two methods that can be used to manage the state of the lock. They are the getState() and setState() methods. These methods receive and return an integer value with the state of the lock. You could have used them instead of the AtomicInteger attribute to store the state of the lock.

The Java Concurrency API provides another class to implement synchronization mechanisms. It's the AbstractQueuedLongSynchronizer class, which is equivalent to AbstractQueuedSynchronizer but uses a long attribute to store the state of the threads.

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