Top Description Fields Constructors Methods
org.springframework.scheduling.concurrent

pack-priv final Class ExecutorLifecycleDelegate

extends Object
implements SmartLifecycle
Class Inheritance
All Implemented Interfaces
org.springframework.context.SmartLifecycle, org.springframework.context.Phased, org.springframework.context.Lifecycle
Imports
java.util.concurrent.ExecutorService, java.util.concurrent.locks.Condition, .Lock, .ReentrantLock, org.springframework.context.SmartLifecycle, org.springframework.lang.Nullable

An internal delegate for common ExecutorService lifecycle management with pause/resume support.
Author
Juergen Hoeller
Since
6.1
See Also
ExecutorConfigurationSupport, SimpleAsyncTaskScheduler

Field Summary

Modifier and TypeField and Description
private int
private final ExecutorService
private volatile boolean
private final Lock
private volatile boolean
private Runnable
private final Condition

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv void
public boolean
isRunning()

Implements org.springframework.context.Lifecycle.isRunning.

Check whether this component is currently running.

pack-priv void
public void
start()

Implements org.springframework.context.Lifecycle.start.

Start this component.

public void
stop()

Implements org.springframework.context.Lifecycle.stop.

Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method.

public void
stop(Runnable callback)

Overrides default org.springframework.context.SmartLifecycle.stop.

Indicates that a Lifecycle component must stop if it is currently running.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

executingTaskCountback to summary
private int executingTaskCount
executorback to summary
private final ExecutorService executor
pausedback to summary
private volatile boolean paused
pauseLockback to summary
private final Lock pauseLock
shutdownback to summary
private volatile boolean shutdown
stopCallbackback to summary
private Runnable stopCallback
Annotations
@Nullable
unpausedback to summary
private final Condition unpaused

Constructor Detail

ExecutorLifecycleDelegateback to summary
public ExecutorLifecycleDelegate(ExecutorService executor)

Method Detail

afterExecuteback to summary
pack-priv void afterExecute()
beforeExecuteback to summary
pack-priv void beforeExecute(Thread thread)
isRunningback to summary
public boolean isRunning()

Implements org.springframework.context.Lifecycle.isRunning.

Doc from org.springframework.context.Lifecycle.isRunning.

Check whether this component is currently running.

In the case of a container, this will return true only if all components that apply are currently running.

Returns:boolean

whether the component is currently running

Annotations
@Override
markShutdownback to summary
pack-priv void markShutdown()
startback to summary
public void start()

Implements org.springframework.context.Lifecycle.start.

Doc from org.springframework.context.Lifecycle.start.

Start this component.

Should not throw an exception if the component is already running.

In the case of a container, this will propagate the start signal to all components that apply.

Annotations
@Override
stopback to summary
public void stop()

Implements org.springframework.context.Lifecycle.stop.

Doc from org.springframework.context.Lifecycle.stop.

Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method. Consider implementing SmartLifecycle and its stop(Runnable) variant when asynchronous stop behavior is necessary.

Note that this stop notification is not guaranteed to come before destruction: On regular shutdown, Lifecycle beans will first receive a stop notification before the general destruction callbacks are being propagated; however, on hot refresh during a context's lifetime or on aborted refresh attempts, a given bean's destroy method will be called without any consideration of stop signals upfront.

Should not throw an exception if the component is not running (not started yet).

In the case of a container, this will propagate the stop signal to all components that apply.

Annotations
@Override
stopback to summary
public void stop(Runnable callback)

Overrides default org.springframework.context.SmartLifecycle.stop.

Doc from org.springframework.context.SmartLifecycle.stop.

Indicates that a Lifecycle component must stop if it is currently running.

The provided callback is used by the LifecycleProcessor to support an ordered, and potentially concurrent, shutdown of all components having a common shutdown order value. The callback must be executed after the SmartLifecycle component does indeed stop.

The LifecycleProcessor will call only this variant of the stop method; i.e. Lifecycle#stop() will not be called for SmartLifecycle implementations unless explicitly delegated to within the implementation of this method.

The default implementation delegates to stop() and immediately triggers the given callback in the calling thread. Note that there is no synchronization between the two, so custom implementations may at least want to put the same steps within their common lifecycle monitor (if any).

Annotations
@Override