ReleasableExecutor


@UnstableApi
public interface ReleasableExecutor extends Executor


An Executor with a dedicated release method to signal when it is not longer needed.

Summary

Public methods

default static ReleasableExecutor
<T extends Executor> from(T executor, Consumer<T> releaseCallback)

Creates a ReleasableExecutor from an Executor and a release callback.

abstract void

Releases the Executor, indicating that the caller no longer requires it for executing new commands.

Inherited methods

From java.util.concurrent.Executor
abstract void

Public methods

from

default static ReleasableExecutor <T extends Executor> from(T executor, Consumer<T> releaseCallback)

Creates a ReleasableExecutor from an Executor and a release callback.

Parameters
<T extends Executor>

The type of Executor.

T executor

The Executor

Consumer<T> releaseCallback

The release callback, accepting the executor as an argument.

Returns
ReleasableExecutor

The releasable executor.

release

abstract void release()

Releases the Executor, indicating that the caller no longer requires it for executing new commands.

When calling this method, there may still be pending commands that are currently executed.