Skip to Content
Java in a Nutshell, 5th Edition
book

Java in a Nutshell, 5th Edition

by David Flanagan
March 2005
Intermediate to advanced
1254 pages
104h 21m
English
O'Reilly Media, Inc.
Content preview from Java in a Nutshell, 5th Edition

Name

Package java.util.concurrent.locks

Synopsis

This package defines Lock and associated Condition interfaces as well as concrete implementations (such as ReentrantLock) that provide an alternative to locking with synchronized blocks and methods and to waiting with the wait( ), notify( ), and notifyAll( ) methods of Object.

Although Lock and Condition are somewhat more complex to use than the built-in locking, waiting, and notification mechanisms of Object, they are also more flexible. Lock, for example, does not require that locks be block-structured and enables algorithms such as “hand-over-hand locking” for traversing linked data structures. A thread waiting to acquire a Lock can time out or be interrupted, which is not possible with synchronized locking. Also, more than one Condition can be associated with a given Lock, which is simply not possible with Object-based locking and waiting.

The ReadWriteLock interface and its ReentrantReadWriteLock implementation allow multiple concurrent readers but only a single writer thread to hold the lock.

Interfaces

public interface Condition;
public interface Lock;
public interface ReadWriteLock;

Classes

public abstract class AbstractQueuedSynchronizer implements Serializable;
public class AbstractQueuedSynchronizer.ConditionObject implements Condition, Serializable;
public class LockSupport;
public class ReentrantLock implements Lock, Serializable;
public class ReentrantReadWriteLock implements ReadWriteLock, Serializable; public static class ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java in a Nutshell, 8th Edition

Java in a Nutshell, 8th Edition

Benjamin J. Evans, Jason Clark, David Flanagan
Java in a Nutshell, 7th Edition

Java in a Nutshell, 7th Edition

Benjamin J. Evans, David Flanagan
Learning Java, 5th Edition

Learning Java, 5th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck
Learning Java, 4th Edition

Learning Java, 4th Edition

Patrick Niemeyer, Daniel Leuck

Publisher Resources

ISBN: 0596007736Supplemental ContentErrata Page