Colt 1.0.1

Package edu.oswego.cs.dl.util.concurrent

Standardized, efficient utility classes commonly encountered in concurrent programming.

See:
          Description

Interface Summary
Barrier Barriers serve as synchronization points for groups of threads that must occasionally wait for each other.
BoundedChannel A channel that is known to have a capacity, signifying that put operations may block when the capacity is reached.
Callable Interface for runnable actions that bear results and/or throw Exceptions.
Channel Main interface for buffers, queues, pipes, conduits, etc.
Executor Interface for objects that execute Runnables, as well as various objects that can be wrapped as Runnables.
ObservableSync.SyncObserver Interface for objects that observe ObservableSyncs.
Puttable This interface exists to enable stricter type checking for channels.
ReadWriteLock ReadWriteLocks maintain a pair of associated locks.
Rendezvous.RendezvousFunction Interface for functions run at rendezvous points
Sync Main interface for locks, gates, and conditions.
Takable This interface exists to enable stricter type checking for channels.
ThreadFactory Interface describing any class that can generate new Thread objects.
 

Class Summary
BoundedBuffer Efficient array-based bounded buffer class.
BoundedLinkedQueue A bounded variant of LinkedQueue class.
BoundedPriorityQueue A heap-based priority queue, using semaphores for concurrency control.
ClockDaemon A general-purpose time-based daemon, vaguely similar in functionality to common system-level utilities such as at (and the associated crond) in Unix.
CondVar This class is designed for fans of POSIX pthreads programming.
CopyOnWriteArrayList This class implements a variant of java.util.ArrayList in which all mutative operations (add, set, and so on) are implemented by making a fresh copy of the underlying array.
CopyOnWriteArraySet This class implements a java.util.Set that uses a CopyOnWriteArrayList for all of its operations.
CountDown A CountDown can serve as a simple one-shot barrier.
CyclicBarrier A cyclic barrier is a reasonable choice for a barrier in contexts involving a fixed sized group of threads that must occasionally wait for each other.
DefaultChannelCapacity A utility class to set the default capacity of BoundedChannel implementations that otherwise require a capacity argument
DirectExecutor An implementation of Executor that invokes the run method of the supplied command and then returns.
FIFOReadWriteLock This class implements a policy for reader/writer locks in which incoming readers and writers contend in generally fair manner for entry.
FIFOSemaphore A First-in/First-out implementation of a Semaphore.
FJTask Abstract base class for Fork/Join Tasks.
FJTask.Par A new Par, when executed, runs the tasks provided in the constructor in parallel using coInvoke(tasks).
FJTask.Par2 A new Par(task1, task2), when executed, runs task1 and task2 in parallel using coInvoke(task1, task2).
FJTask.Seq A new Seq, when executed, invokes each task provided in the constructor, in order.
FJTask.Seq2 A new Seq2(task1, task2), when executed, invokes task1 and then task2, in order.
FJTask.Wrap A FJTask that holds a Runnable r, and calls r.run when executed.
FJTaskRunner Specialized Thread subclass for running FJTasks.
FJTaskRunnerGroup A stripped down analog of a ThreadGroup used for establishing and managing FJTaskRunner threads.
FutureResult A class maintaining a single reference variable serving as the result of an operation.
Heap A heap-based priority queue, without any concurrency control (i.e., no blocking on empty/full states).
Latch A latch is a boolean condition that is set at most once, ever.
LayeredSync A class that can be used to compose Syncs.
LinkedQueue A linked list based channel implementation.
LockedExecutor An implementation of Executor that invokes the run method of the supplied command within a synchronization lock and then returns.
Mutex A simple non-reentrant mutual exclusion lock.
NullSync A No-Op implementation of Sync.
ObservableSync The ObservableSync class performs no synchronization itself, but invokes event-style messages to other observer objects upon invocation of Sync methods.
PooledExecutor A tunable, extensible thread pool class.
PrioritySemaphore A Semaphore that grants requests to threads with higher Thread priority rather than lower priority when there is contention.
PropertyChangeMulticaster This class is interoperable with java.beans.PropertyChangeSupport, but relies on a streamlined copy-on-write scheme similar to that used in CopyOnWriteArrayList.
QueuedExecutor An implementation of Executor that queues incoming requests until they can be processed by a single background thread.
QueuedSemaphore Abstract base class for semaphores relying on queued wait nodes
ReaderPreferenceReadWriteLock A ReadWriteLock that prefers waiting readers over waiting writers when there is contention.
ReentrantLock A lock with the same semantics as builtin Java synchronized locks: Once a thread has a lock, it can re-obtain it any number of times without blocking.
ReentrantWriterPreferenceReadWriteLock A writer-preference ReadWriteLock that allows writers to reacquire read or write locks in the style of a ReentrantLock.
Rendezvous A rendezvous is a barrier that: Unlike a CyclicBarrier, is not restricted to use with fixed-sized groups of threads.
Rendezvous.Rotator The default rendezvous function.
Semaphore Base class for counting semaphores.
SemaphoreControlledChannel Abstract class for channels that use Semaphores to control puts and takes.
Slot A one-slot buffer, using semaphores to control access.
SyncCollection SyncCollections wrap Sync-based control around java.util.Collections.
SynchronizedBoolean A class useful for offloading synch for boolean instance variables.
SynchronizedByte A class useful for offloading synch for byte instance variables.
SynchronizedChar A class useful for offloading synch for char instance variables.
SynchronizedDouble A class useful for offloading synch for double instance variables.
SynchronizedFloat A class useful for offloading synch for float instance variables.
SynchronizedInt A class useful for offloading synch for int instance variables.
SynchronizedLong A class useful for offloading synch for long instance variables.
SynchronizedRef A simple class maintaining a single reference variable that is always accessed and updated under synchronization.
SynchronizedShort A class useful for offloading synch for short instance variables.
SynchronizedVariable Base class for simple, small classes maintaining single values that are always accessed and updated under synchronization.
SynchronousChannel [ Introduction to this package.
SyncList SyncLists wrap Sync-based control around java.util.Lists.
SyncMap SyncMaps wrap Sync-based control around java.util.Maps.
SyncSet SyncSets wrap Sync-based control around java.util.Sets.
SyncSortedMap SyncSortedMaps wrap Sync-based control around java.util.SortedMaps.
SyncSortedSet SyncSortedSets wrap Sync-based control around java.util.SortedSets.
ThreadedExecutor An implementation of Executor that creates a new Thread that invokes the run method of the supplied command.
ThreadFactoryUser Base class for Executors and related classes that rely on thread factories.
TimeDaemon A general-purpose timer daemon, vaguely similar in functionality common system-level utilities like at (and the associated crond) in Unix.
TimeoutSync A TimeoutSync is an adaptor class that transforms all calls to acquire to instead invoke attempt with a predetermined timeout value.
VetoableChangeMulticaster This class is interoperable with java.beans.VetoableChangeSupport, but relies on a streamlined copy-on-write scheme similar to that used in CopyOnWriteArrayList.
WaitableBoolean A class useful for offloading synch for boolean instance variables.
WaitableByte A class useful for offloading waiting and signalling operations on single byte variables.
WaitableChar A class useful for offloading waiting and signalling operations on single char variables.
WaitableDouble A class useful for offloading waiting and signalling operations on single double variables.
WaitableFloat A class useful for offloading waiting and signalling operations on single float variables.
WaitableInt A class useful for offloading waiting and signalling operations on single int variables.
WaitableLong A class useful for offloading waiting and signalling operations on single long variables.
WaitableRef A class useful for offloading synch for Object reference instance variables.
WaitableShort A class useful for offloading waiting and signalling operations on single short variables.
WaiterPreferenceSemaphore An implementation of counting Semaphores that enforces enough fairness for applications that need to avoid indefinite overtaking without necessarily requiring FIFO ordered access.
WaitFreeQueue A wait-free linked list based queue implementation, adapted from the algorithm described in Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms by Maged M.
WriterPreferenceReadWriteLock A ReadWriteLock that prefers waiting writers over waiting readers when there is contention.
 

Exception Summary
BrokenBarrierException Thrown by Barrier upon interruption of participant threads
TimeoutException Thrown by synchronization classes that report timeouts via exceptions.
 

Package edu.oswego.cs.dl.util.concurrent Description

Standardized, efficient utility classes commonly encountered in concurrent programming.

For the master version of this page (more up-to-date, more info) please go to http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html)

Overview of package util.concurrent Release 1.2.5

by Doug Lea

This package provides standardized, efficient versions of utility classes commonly encountered in concurrent Java programming. It mainly consists of implementations of a few interfaces:

Plus some utilities and frameworks that build upon these.

Contents

Sync
Interface for classes used as exclusion, resource management, and related synchronization aids, supporting methods acquire, attempt(msecs), and release.

Implementations

Semaphore
Semaphores of various sorts. The default implementation provides no special ordering guarantees. Subclasses that do include:
WaiterPreferenceSemaphore
Provides protection against barging (infinite overtaking)
FIFOSemaphore
Provides first-in/first-out ordering
PrioritySemaphore
Prefers notifications to higher-priority threads
Mutex
Basic non-reentrant mutual exclusion lock
ReentrantLock
Java-style per-thread mutual exclusion lock
Latch
A condition that is acquirable forever more after the first release
CountDown
A condition that is acquirable forever more after the nth release.

The following implementation classes do not themselves perform any synchronization, but serve as adaptors, glue, and extensibility hooks for those that do. They may also be helpful when using Syncs in generic before/after constructions:

NullSync
A no-op implementation: acquire and attempt always succeed.
TimeoutSync
Routes all calls to acquire to use attempt with a predefined timeout value.
LayeredSync
Cascades operations of two Syncs
ObservableSync
Issues calls to SyncObservers upon each acquire and release.

Related Classes

CondVar
Support for POSIX (pthreads) style condition variables
TimeoutException
A standardized time-out exception class

ReadWriteLock
Interface for pairs of locks, one for reading, and one for writing.

Implementations

WriterPreferenceReadWriteLock
The most useful and common policy
ReentrantWriterPreferenceReadWriteLock
Allows multiple lock holds as well as lock downgrading by writers.
ReaderPreferenceReadWriteLock
Prefers waiting readers to waiting writers.
FIFOReadWriteLock
Prefers either a writer or readers, depending on which one arrived first.

Barrier
Synchronization points for groups of threads.

Implementations

CyclicBarrier
A tool to force multiple threads to synchronize at a given point
Rendezvous
A cyclic barrier that does not rely on there being a predetermined number of participant threads, and allows threads to exchange information at each barrier point.

Related Classes

BrokenBarrierException
A standardized exception for barrier synchronization failures

Channel
Interface for queues, buffers, conduits and pipes supporting blocking put and take, as well as timeout-based offer and poll. To assist efforts to use channels with somewhat greater type safety, Channel is defined as a subinterface of Puttable and Takable, each defining only one side of the channel. Also, the BoundedChannel subinterface is used for channels with finite capacities.

Implementations

LinkedQueue
An unbounded linked-list-based queue
BoundedLinkedQueue
A linked queue with a capacity bound
BoundedBuffer
An array-based bounded buffer
Slot
A one-slot bounded buffer. (Note that this can also serve as a restricted form of Synchronized variable.)
SynchronousChannel
A zero-slot CSP/Ada-style channel in which every put must wait for a take, and vice versa.
BoundedPriorityQueue
A channel based on a Heap data structure. Elements must either be Comparable, or comparable using a supplied Comparator
WaitFreeQueue
An unbounded linked-list-based queue relying on atomic commits and retries rather than wait/notify.

Related Classes

DefaultChannelCapacity
A utility class that makes it easier to set default capacities for channels that have a capacity that must otherwise be set in constructors.

Executor
Interface for objects that execute Runnable commands.

Implementations

DirectExecutor
An implementation that just directly runs command in current thread.
LockedExecutor
An implementation that directly runs command within a supplied Sync lock in current thread.
ThreadedExecutor
An implementation that runs each command in a new thread.
QueuedExecutor
An implementation that queues commands for execution by a single background thread.
PooledExecutor
A tunable, extensible thread pool class

Related classes

Callable
Interface for runnable actions that return results
FutureResult
Holder for results of actions that can be set by Callables.
ThreadFactory
Interface for objects that create Thread objects
ThreadFactoryUser
Convenient base for classes that use ThreadFactories.
ClockDaemon
A utility for executing commands at given times, after given delays, or periodically with given cycles.

Fork/Join Tasks
A fast lightweight task framework built upon Java threads, and geared for parallel computation. (See also an in-progress draft discussing parallel decomposition using Tasks.)
FJTask
Abstract Base class for tasks.
FJTaskRunnerGroup
Control class for running Tasks.
FJTaskRunner
Underlying specialized Thread subclass for running Tasks.
Demos and examples
A directory of sample programs that use the Task framework.

Collections
Implementations of java.util.Collection and related classes that can help solve concurrency problems.
CopyOnWriteArrayList
A copy-on-write analog of java.util.ArrayList
CopyOnWriteArraySet
A java.util.Set based on CopyOnWriteArrayList.
SyncCollection
A wrapper class placing either Syncs or ReadWriteLocks around java.util.Collection
SyncSet
A wrapper around java.util.Set
SyncSortedSet
A wrapper around java.util.SortedSet
SyncList
A wrapper around java.util.List
SyncMap
A wrapper around java.util.Map
SyncSortedMap
A wrapper around java.util.SortedMap
Related classes
PropertyChangeMulticaster
A copy-on-write replacement for java.beans.PropertyChangeSupport
VetoableChangeMulticaster
A copy-on-write replacement for java.beans.VetoableChangeSupport

SynchronizedVariable
Simple synchronized analogs of Number and Ref classes in java.lang. Each has a subclass that in addition to maintaining synchronization, also provides notifications upon value changes and supports guarded waits.

Miscellany
There are some classes in the misc directory that might be of interest but aren't really part of this package. They include:

Notes

History


Doug Lea
Last modified: Sat Oct 23 19:47:08 EDT 1999


Colt 1.0.1

Submit a bug or feature. Check the Colt home page for the latest news.