@ParametersAreNonnullByDefault
Package com.google.common.util.concurrent
Concurrency utilities.
Commonly used types include ListenableFuture
and
Service
.
Commonly used utilities include Futures
, MoreExecutors
, and ThreadFactoryBuilder
.
This package is a part of the open-source Guava library.
-
Interface Summary Interface Description AsyncCallable<V> Computes a value, possibly asynchronously.AsyncFunction<I,O> Transforms a value, possibly asynchronously.CheckedFuture<V,X extends java.lang.Exception> Deprecated. CheckedFuture
cannot properly support the chained operations that are the primary goal ofListenableFuture
.CycleDetectingLockFactory.CycleDetectingLock Internal Lock implementations implement theCycleDetectingLock
interface, allowing the detection logic to treat all locks in the same manner.CycleDetectingLockFactory.Policy Encapsulates the action to be taken when a potential deadlock is encountered.FutureCallback<V> A callback for accepting the results of aFuture
computation asynchronously.FuturesGetChecked.GetCheckedTypeValidator ListenableFuture<V> AFuture
that accepts completion listeners.ListenableScheduledFuture<V> Helper interface to implement bothListenableFuture
andScheduledFuture
.ListenerCallQueue.Event<L> Method reference-compatible listener event.ListeningExecutorService AnExecutorService
that returnsListenableFuture
instances.ListeningScheduledExecutorService AScheduledExecutorService
that returnsListenableFuture
instances from itsExecutorService
methods.Service An object with an operational state, plus asynchronousService.startAsync()
andService.stopAsync()
lifecycle methods to transition between states.TimeLimiter Imposes a time limit on method calls. -
Class Summary Class Description AbstractCatchingFuture<V,X extends java.lang.Throwable,F,T> Implementations ofFutures.catching*
.AbstractCatchingFuture.AsyncCatchingFuture<V,X extends java.lang.Throwable> AnAbstractCatchingFuture
that delegates to anAsyncFunction
andAbstractFuture.setFuture(ListenableFuture)
.AbstractCatchingFuture.CatchingFuture<V,X extends java.lang.Throwable> AbstractCheckedFuture<V,X extends java.lang.Exception> Deprecated. CheckedFuture
cannot properly support the chained operations that are the primary goal ofListenableFuture
.AbstractExecutionThreadService Base class for services that can implementAbstractExecutionThreadService.startUp()
,AbstractExecutionThreadService.run()
andAbstractExecutionThreadService.shutDown()
methods.AbstractFuture<V> An abstract implementation ofListenableFuture
, intended for advanced users only.AbstractFuture.AtomicHelper AbstractFuture.Cancellation A special value to represent cancellation and the 'wasInterrupted' bit.AbstractFuture.Failure A special value to represent failure, whenAbstractFuture.setException(java.lang.Throwable)
is called successfully.AbstractFuture.Listener Listeners also form a stack through theAbstractFuture.listeners
field.AbstractFuture.SafeAtomicHelper AbstractFuture.AtomicHelper
based onAtomicReferenceFieldUpdater
.AbstractFuture.SetFuture<V> A special value that encodes the 'setFuture' state.AbstractFuture.SynchronizedHelper AbstractFuture.AtomicHelper
based onsynchronized
and volatile writes.AbstractFuture.TrustedFuture<V> A less abstract subclass of AbstractFuture.AbstractFuture.UnsafeAtomicHelper AbstractFuture.AtomicHelper
based onUnsafe
.AbstractFuture.Waiter Waiter links form a Treiber stack, in theAbstractFuture.waiters
field.AbstractIdleService Base class for services that do not need a thread while "running" but may need one during startup and shutdown.AbstractListeningExecutorService AbstractListeningExecutorService
implementation that createsListenableFuture
instances for eachRunnable
andCallable
submitted to it.AbstractScheduledService Base class for services that can implementAbstractScheduledService.startUp()
andAbstractScheduledService.shutDown()
but while in the "running" state need to perform a periodic task.AbstractScheduledService.CustomScheduler AAbstractScheduledService.Scheduler
that provides a convenient way for theAbstractScheduledService
to use a dynamically changing schedule.AbstractScheduledService.CustomScheduler.Schedule A value object that represents an absolute delay until a task should be invoked.AbstractScheduledService.Scheduler A scheduler defines the policy for how theAbstractScheduledService
should run its task.AbstractService Base class for implementing services that can handleAbstractService.doStart()
andAbstractService.doStop()
requests, responding to them withAbstractService.notifyStarted()
andAbstractService.notifyStopped()
callbacks.AbstractService.StateSnapshot An immutable snapshot of the current state of the service.AbstractTransformFuture<I,O,F,T> Implementations ofFutures.transform*
.AbstractTransformFuture.AsyncTransformFuture<I,O> AnAbstractTransformFuture
that delegates to anAsyncFunction
andAbstractFuture.setFuture(ListenableFuture)
.AbstractTransformFuture.TransformFuture<I,O> AggregateFuture<InputT,OutputT> A future made up of a collection of sub-futures.AggregateFutureState A helper which does some thread-safe operations for aggregate futures, which must be implemented differently in GWT.AggregateFutureState.AtomicHelper AggregateFutureState.SafeAtomicHelper AggregateFutureState.SynchronizedAtomicHelper AtomicDouble Adouble
value that may be updated atomically.AtomicDoubleArray Adouble
array in which elements may be updated atomically.AtomicLongMap<K> A map containinglong
values that can be atomically updated.Atomics Static utility methods pertaining to classes in thejava.util.concurrent.atomic
package.Callables Static utility methods pertaining to theCallable
interface.CollectionFuture<V,C> Aggregate future that collects (stores) results of each future.CollectionFuture.ListFuture<V> CombinedFuture<V> Aggregate future that computes its value by calling a callable.CycleDetectingLockFactory TheCycleDetectingLockFactory
createsReentrantLock
instances andReentrantReadWriteLock
instances that detect potential deadlock by checking for cycles in lock acquisition order.CycleDetectingLockFactory.LockGraphNode ALockGraphNode
associated with each lock instance keeps track of the directed edges in the lock acquisition graph.CycleDetectingLockFactory.WithExplicitOrdering<E extends java.lang.Enum<E>> ACycleDetectingLockFactory.WithExplicitOrdering
provides the additional enforcement of an application-specified ordering of lock acquisitions.ExecutionList A support class forListenableFuture
implementations to manage their listeners.ExecutionList.RunnableExecutorPair FakeTimeLimiter A TimeLimiter implementation which actually does not attempt to limit time at all.FluentFuture<V> AListenableFuture
that supports fluent chains of operations.ForwardingBlockingDeque<E> ABlockingDeque
which forwards all its method calls to anotherBlockingDeque
.ForwardingBlockingQueue<E> ABlockingQueue
which forwards all its method calls to anotherBlockingQueue
.ForwardingCheckedFuture<V,X extends java.lang.Exception> Deprecated. CheckedFuture
cannot properly support the chained operations that are the primary goal ofListenableFuture
.ForwardingCheckedFuture.SimpleForwardingCheckedFuture<V,X extends java.lang.Exception> Deprecated. CheckedFuture
cannot properly support the chained operations that are the primary goal ofListenableFuture
.ForwardingCondition Forwarding wrapper around aCondition
.ForwardingExecutorService An executor service which forwards all its method calls to another executor service.ForwardingFluentFuture<V> FluentFuture
that forwards all calls to a delegate.ForwardingFuture<V> AFuture
which forwards all its method calls to another future.ForwardingFuture.SimpleForwardingFuture<V> A simplified version ofForwardingFuture
where subclasses can pass in an already constructedFuture
as the delegate.ForwardingListenableFuture<V> AListenableFuture
which forwards all its method calls to another future.ForwardingListenableFuture.SimpleForwardingListenableFuture<V> A simplified version ofForwardingListenableFuture
where subclasses can pass in an already constructedListenableFuture
as the delegate.ForwardingListeningExecutorService A listening executor service which forwards all its method calls to another listening executor service.ForwardingLock Forwarding wrapper around aLock
.Futures Static utility methods pertaining to theFuture
interface.Futures.CallbackListener<V> SeeFutures.addCallback(ListenableFuture, FutureCallback, Executor)
for behavioral notes.Futures.FutureCombiner<V> A helper to create a newListenableFuture
whose result is generated from a combination of input futures.Futures.InCompletionOrderFuture<T> Futures.InCompletionOrderState<T> Futures.MappingCheckedFuture<V,X extends java.lang.Exception> A checked future that uses a function to map from exceptions to the appropriate checked type.Futures.NonCancellationPropagatingFuture<V> A wrapped future that does not propagate cancellation to its delegate.FuturesGetChecked Static methods used to implementFutures.getChecked(Future, Class)
.FuturesGetChecked.GetCheckedTypeValidatorHolder Provides a check of whether an exception type is valid for use withFuturesGetChecked.getChecked(Future, Class)
, possibly using caching.GwtFluentFutureCatchingSpecialization<V> Hidden superclass ofFluentFuture
that provides us a place to declare special GWT versions of theFluentFuture.catching
family of methods.GwtFuturesCatchingSpecialization Hidden superclass ofFutures
that provides us a place to declare special GWT versions of theFutures.catching
family of methods.ImmediateFuture<V> Implementations ofFutures.immediate*
.ImmediateFuture.ImmediateCancelledFuture<V> ImmediateFuture.ImmediateFailedCheckedFuture<V,X extends java.lang.Exception> ImmediateFuture.ImmediateFailedFuture<V> ImmediateFuture.ImmediateSuccessfulCheckedFuture<V,X extends java.lang.Exception> ImmediateFuture.ImmediateSuccessfulFuture<V> InterruptibleTask<T> InterruptibleTask.DoNothingRunnable JdkFutureAdapters Utilities necessary for working with libraries that supply plainFuture
instances.JdkFutureAdapters.ListenableFutureAdapter<V> An adapter to turn aFuture
into aListenableFuture
.ListenableFutureTask<V> AFutureTask
that also implements theListenableFuture
interface.ListenerCallQueue<L> A list of listeners for implementing a concurrency friendly observable object.ListenerCallQueue.PerListenerQueue<L> A special purpose queue/executor that dispatches listener events serially on a configured executor.Monitor A synchronization abstraction supporting waiting on arbitrary boolean conditions.Monitor.Guard A boolean condition for which a thread may wait.MoreExecutors Factory and utility methods forExecutor
,ExecutorService
, andThreadFactory
.MoreExecutors.Application Represents the current application to register shutdown hooks.MoreExecutors.DirectExecutorService MoreExecutors.ListeningDecorator MoreExecutors.ScheduledListeningDecorator MoreExecutors.ScheduledListeningDecorator.ListenableScheduledTask<V> MoreExecutors.ScheduledListeningDecorator.NeverSuccessfulListenableFutureTask Partially Outer class that exists solely to let us writePartially.GwtIncompatible
instead of plainGwtIncompatible
.Platform Methods factored out so that they can be emulated differently in GWT.RateLimiter A rate limiter.RateLimiter.SleepingStopwatch Runnables Static utility methods pertaining to theRunnable
interface.SequentialExecutor Executor ensuring that all Runnables submitted are executed in order, using the provided Executor, and sequentially such that no two will ever be running at the same time.Service.Listener A listener for the various state changes that aService
goes through in its lifecycle.ServiceManager A manager for monitoring and controlling a set of services.ServiceManager.EmptyServiceManagerWarning This is never thrown but only used for logging.ServiceManager.FailedService ServiceManager.Listener A listener for the aggregate state changes of the services that are under management.ServiceManager.NoOpService AService
instance that does nothing.ServiceManager.ServiceListener AService
that wraps another service and times how long it takes for it to start and also calls theServiceManager.ServiceManagerState.transitionService(Service, State, State)
, to record the state transitions.ServiceManager.ServiceManagerState An encapsulation of all the mutable state of theServiceManager
that needs to be accessed by instances ofServiceManager.ServiceListener
.SettableFuture<V> AListenableFuture
whose result can be set by aSettableFuture.set(Object)
,SettableFuture.setException(Throwable)
orSettableFuture.setFuture(ListenableFuture)
call.SimpleTimeLimiter A TimeLimiter that runs method calls in the background using anExecutorService
.SmoothRateLimiter SmoothRateLimiter.SmoothBursty This implements a "bursty" RateLimiter, where storedPermits are translated to zero throttling.SmoothRateLimiter.SmoothWarmingUp This implements the following function where coldInterval = coldFactor * stableInterval.Striped<L> A stripedLock/Semaphore/ReadWriteLock
.Striped.CompactStriped<L> Implementation of Striped where 2^k stripes are represented as an array of the same length, eagerly initialized.Striped.LargeLazyStriped<L> Implementation of Striped where up to 2^k stripes can be represented, using a ConcurrentMap where the key domain is [0..2^k).Striped.PaddedLock Striped.PaddedSemaphore Striped.PowerOfTwoStriped<L> Striped.SmallLazyStriped<L> Implementation of Striped where up to 2^k stripes can be represented, using an AtomicReferenceArray of size 2^k.Striped.SmallLazyStriped.ArrayReference<L> Striped.WeakSafeCondition Condition object that ensures a strong reference is retained to a specified object.Striped.WeakSafeLock Lock object that ensures a strong reference is retained to a specified object.Striped.WeakSafeReadWriteLock ReadWriteLock implementation whose read and write locks retain a reference back to this lock.ThreadFactoryBuilder A ThreadFactory builder, providing any combination of these features: whether threads should be marked as daemon threads a naming format a thread priority an uncaught exception handler a backing thread factoryTimeoutFuture<V> Implementation ofFutures#withTimeout
.TimeoutFuture.Fire<V> A runnable that is called when the delegate or the timer completes.TrustedListenableFutureTask<V> ARunnableFuture
that also implements theListenableFuture
interface.UncaughtExceptionHandlers Factories forThread.UncaughtExceptionHandler
instances.UncaughtExceptionHandlers.Exiter Uninterruptibles Utilities for treating interruptible operations as uninterruptible.WrappingExecutorService An abstractExecutorService
that allows subclasses to wrap tasks before they are submitted to the underlying executor.WrappingScheduledExecutorService An abstractScheduledExecutorService
that allows subclasses to wrap tasks before they are submitted to the underlying executor. -
Enum Summary Enum Description CycleDetectingLockFactory.Policies Pre-definedCycleDetectingLockFactory.Policy
implementations.FuturesGetChecked.GetCheckedTypeValidatorHolder.ClassValueValidator FuturesGetChecked.GetCheckedTypeValidatorHolder.WeakSetValidator MoreExecutors.DirectExecutor SeeMoreExecutors.directExecutor()
for behavioral notes.SequentialExecutor.WorkerRunningState Service.State The lifecycle states of a service. -
Exception Summary Exception Description CycleDetectingLockFactory.ExampleStackTrace A Throwable used to record a stack trace that illustrates an example of a specific lock acquisition ordering.CycleDetectingLockFactory.PotentialDeadlockException Represents a detected cycle in lock acquisition ordering.UncheckedExecutionException Unchecked variant ofExecutionException
.UncheckedTimeoutException Unchecked version ofTimeoutException
. -
Error Summary Error Description ExecutionError Error
variant ofExecutionException
. -
Annotation Types Summary Annotation Type Description Partially.GwtIncompatible The presence of this annotation on an API indicates that the method may be used with the Google Web Toolkit (GWT) but that it has some restrictions.