@CheckReturnValue @ParametersAreNonnullByDefault
Package com.google.common.util.concurrent
Concurrency utilities.
Commonly used types include ClosingFuture
, ListenableFuture
, and Service
.
Commonly used utilities include Futures
, MoreExecutors
, ThreadFactoryBuilder
, and Uninterruptibles
.
This package is a part of the open-source Guava library.
-
Interface Summary Interface Description AsyncCallable<V extends @Nullable java.lang.Object> Computes a value, possibly asynchronously.AsyncFunction<I extends @Nullable java.lang.Object,O extends @Nullable java.lang.Object> Transforms a value, possibly asynchronously.ClosingFuture.AsyncClosingCallable<V extends @Nullable java.lang.Object> An operation that computes aClosingFuture
of a result.ClosingFuture.AsyncClosingFunction<T extends @Nullable java.lang.Object,U extends @Nullable java.lang.Object> A function from an input to aClosingFuture
of a result.ClosingFuture.ClosingCallable<V extends @Nullable java.lang.Object> An operation that computes a result.ClosingFuture.ClosingFunction<T extends @Nullable java.lang.Object,U extends @Nullable java.lang.Object> A function from an input to a result.ClosingFuture.Combiner.AsyncCombiningCallable<V extends @Nullable java.lang.Object> An operation that returns aClosingFuture
result and may throw an exception.ClosingFuture.Combiner.CombiningCallable<V extends @Nullable java.lang.Object> An operation that returns a result and may throw an exception.ClosingFuture.Combiner2.AsyncClosingFunction2<V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.Object,U extends @Nullable java.lang.Object> A function that returns aClosingFuture
when applied to the values of the two futures passed toClosingFuture.whenAllSucceed(ClosingFuture, ClosingFuture)
.ClosingFuture.Combiner2.ClosingFunction2<V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.Object,U extends @Nullable java.lang.Object> A function that returns a value when applied to the values of the two futures passed toClosingFuture.whenAllSucceed(ClosingFuture, ClosingFuture)
.ClosingFuture.Combiner3.AsyncClosingFunction3<V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.Object,V3 extends @Nullable java.lang.Object,U extends @Nullable java.lang.Object> A function that returns aClosingFuture
when applied to the values of the three futures passed toClosingFuture.whenAllSucceed(ClosingFuture, ClosingFuture, ClosingFuture)
.ClosingFuture.Combiner3.ClosingFunction3<V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.Object,V3 extends @Nullable java.lang.Object,U extends @Nullable java.lang.Object> A function that returns a value when applied to the values of the three futures passed toClosingFuture.whenAllSucceed(ClosingFuture, ClosingFuture, ClosingFuture)
.ClosingFuture.Combiner4.AsyncClosingFunction4<V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.Object,V3 extends @Nullable java.lang.Object,V4 extends @Nullable java.lang.Object,U extends @Nullable java.lang.Object> A function that returns aClosingFuture
when applied to the values of the four futures passed toClosingFuture.whenAllSucceed(ClosingFuture, ClosingFuture, ClosingFuture, ClosingFuture)
.ClosingFuture.Combiner4.ClosingFunction4<V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.Object,V3 extends @Nullable java.lang.Object,V4 extends @Nullable java.lang.Object,U extends @Nullable java.lang.Object> A function that returns a value when applied to the values of the four futures passed toClosingFuture.whenAllSucceed(ClosingFuture, ClosingFuture, ClosingFuture, ClosingFuture)
.ClosingFuture.Combiner5.AsyncClosingFunction5<V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.Object,V3 extends @Nullable java.lang.Object,V4 extends @Nullable java.lang.Object,V5 extends @Nullable java.lang.Object,U extends @Nullable java.lang.Object> A function that returns aClosingFuture
when applied to the values of the five futures passed toClosingFuture.whenAllSucceed(ClosingFuture, ClosingFuture, ClosingFuture, ClosingFuture, ClosingFuture)
.ClosingFuture.Combiner5.ClosingFunction5<V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.Object,V3 extends @Nullable java.lang.Object,V4 extends @Nullable java.lang.Object,V5 extends @Nullable java.lang.Object,U extends @Nullable java.lang.Object> A function that returns a value when applied to the values of the five futures passed toClosingFuture.whenAllSucceed(ClosingFuture, ClosingFuture, ClosingFuture, ClosingFuture, ClosingFuture)
.ClosingFuture.ValueAndCloserConsumer<V extends @Nullable java.lang.Object> Represents an operation that accepts aClosingFuture.ValueAndCloser
for the last step in aClosingFuture
pipeline.CycleDetectingLockFactory.Policy Encapsulates the action to be taken when a potential deadlock is encountered.FutureCallback<V extends @Nullable java.lang.Object> A callback for accepting the results of aFuture
computation asynchronously.ListenableFuture<V extends @Nullable java.lang.Object> AFuture
that accepts completion listeners.ListenableScheduledFuture<V extends @Nullable java.lang.Object> Helper interface to implement bothListenableFuture
andScheduledFuture
.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 AbstractExecutionThreadService Base class for services that can implementAbstractExecutionThreadService.startUp()
,AbstractExecutionThreadService.run()
andAbstractExecutionThreadService.shutDown()
methods.AbstractFuture<V extends @Nullable java.lang.Object> An abstract implementation ofListenableFuture
, intended for advanced users only.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.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.ClosingFuture<V extends @Nullable java.lang.Object> A step in a pipeline of an asynchronous computation.ClosingFuture.Combiner A builder of aClosingFuture
step that is derived from more than one input step.ClosingFuture.Combiner2<V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.Object> A genericClosingFuture.Combiner
that lets you use a lambda or method reference to combine twoClosingFuture
s.ClosingFuture.Combiner3<V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.Object,V3 extends @Nullable java.lang.Object> A genericClosingFuture.Combiner
that lets you use a lambda or method reference to combine threeClosingFuture
s.ClosingFuture.Combiner4<V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.Object,V3 extends @Nullable java.lang.Object,V4 extends @Nullable java.lang.Object> A genericClosingFuture.Combiner
that lets you use a lambda or method reference to combine fourClosingFuture
s.ClosingFuture.Combiner5<V1 extends @Nullable java.lang.Object,V2 extends @Nullable java.lang.Object,V3 extends @Nullable java.lang.Object,V4 extends @Nullable java.lang.Object,V5 extends @Nullable java.lang.Object> A genericClosingFuture.Combiner
that lets you use a lambda or method reference to combine fiveClosingFuture
s.ClosingFuture.DeferredCloser An object that can capture objects to be closed later, when aClosingFuture
pipeline is done.ClosingFuture.Peeker An object that can return the value of theClosingFuture
s that are passed toClosingFuture.whenAllComplete(Iterable)
orClosingFuture.whenAllSucceed(Iterable)
.ClosingFuture.ValueAndCloser<V extends @Nullable java.lang.Object> An object that holds the final result of an asynchronousClosingFuture
operation and allows the user to close all the closeable objects that were captured during it for later closing.CycleDetectingLockFactory TheCycleDetectingLockFactory
createsReentrantLock
instances andReentrantReadWriteLock
instances that detect potential deadlock by checking for cycles in lock acquisition order.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.ExecutionSequencer Serializes execution of tasks, somewhat like an "asynchronoussynchronized
block."FakeTimeLimiter A TimeLimiter implementation which actually does not attempt to limit time at all.FluentFuture<V extends @Nullable java.lang.Object> 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
.ForwardingExecutorService An executor service which forwards all its method calls to another executor service.ForwardingFuture<V extends @Nullable java.lang.Object> AFuture
which forwards all its method calls to another future.ForwardingFuture.SimpleForwardingFuture<V extends @Nullable java.lang.Object> A simplified version ofForwardingFuture
where subclasses can pass in an already constructedFuture
as the delegate.ForwardingListenableFuture<V extends @Nullable java.lang.Object> AListenableFuture
which forwards all its method calls to another future.ForwardingListenableFuture.SimpleForwardingListenableFuture<V extends @Nullable java.lang.Object> 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.Futures Static utility methods pertaining to theFuture
interface.Futures.FutureCombiner<V extends @Nullable java.lang.Object> A helper to create a newListenableFuture
whose result is generated from a combination of input futures.JdkFutureAdapters Utilities necessary for working with libraries that supply plainFuture
instances.ListenableFutureTask<V extends @Nullable java.lang.Object> AFutureTask
that also implements theListenableFuture
interface.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
.RateLimiter A rate limiter.Runnables Static utility methods pertaining to theRunnable
interface.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.Listener A listener for the aggregate state changes of the services that are under management.SettableFuture<V extends @Nullable java.lang.Object> 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
.Striped<L> A stripedLock/Semaphore/ReadWriteLock
.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 factoryUncaughtExceptionHandlers Factories forThread.UncaughtExceptionHandler
instances.Uninterruptibles Utilities for treating interruptible operations as uninterruptible. -
Enum Summary Enum Description CycleDetectingLockFactory.Policies Pre-definedCycleDetectingLockFactory.Policy
implementations.Service.State The lifecycle states of a service. -
Exception Summary Exception Description 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
.