@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 libraries.
-
Interface Summary Interface Description AsyncFunction<I,O> Transforms a value, possibly asynchronously.CheckedFuture<V,X extends java.lang.Exception> ACheckedFuture
is aListenableFuture
that includes versions of theget
methods that can throw a checked exception.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.FutureFallback<V> Provides a backupFuture
to replace an earlier failedFuture
.ListenableFuture<V> AFuture
that accepts completion listeners.ListenableScheduledFuture<V> 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 Produces proxies that impose a time limit on method calls to the proxied object. -
Class Summary Class Description AbstractCheckedFuture<V,X extends java.lang.Exception> A delegating wrapper around aListenableFuture
that adds support for theAbstractCheckedFuture.checkedGet()
andAbstractCheckedFuture.checkedGet(long, TimeUnit)
methods.AbstractExecutionThreadService Base class for services that can implementAbstractExecutionThreadService.startUp()
,AbstractExecutionThreadService.run()
andAbstractExecutionThreadService.shutDown()
methods.AbstractFuture<V> An abstract implementation of theListenableFuture
interface.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 createsListenableFutureTask
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.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.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 list of listeners, each with an associatedExecutor
, that guarantees that everyRunnable
that is added will be executed afterExecutionList.execute()
is called.FakeTimeLimiter A TimeLimiter implementation which actually does not attempt to limit time at all.ForwardingBlockingQueue<E> ABlockingQueue
which forwards all its method calls to anotherBlockingQueue
.ForwardingCheckedFuture<V,X extends java.lang.Exception> A future which forwards all its method calls to another future.ForwardingCheckedFuture.SimpleForwardingCheckedFuture<V,X extends java.lang.Exception> A simplified version ofForwardingCheckedFuture
where subclasses can pass in an already constructedCheckedFuture
as the delegate.ForwardingExecutorService An executor service which forwards all its method calls to another executor service.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.ForwardingService Deprecated. Instead of using aForwardingService
, consider using theService.Listener
functionality to hook into theService
lifecycle, or if you really do need to provide access to some Service methods, consider just providing the few that you actually need (e.g.Futures Static utility methods pertaining to theFuture
interface.JdkFutureAdapters Utilities necessary for working with libraries that supply plainFuture
instances.ListenableFutureTask<V> 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.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 ofservices
.ServiceManager.Listener A listener for the aggregate state changes of the services that are under management.SettableFuture<V> AListenableFuture
whose result may be set by aSettableFuture.set(Object)
orSettableFuture.setException(Throwable)
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
.