Verified Owner
Top Description Inners Fields Constructors Methods
org.jabref.logic.util

public Class HeadlessExecutorService

extends Object
implements Executor
Class Inheritance
All Implemented Interfaces
java.util.concurrent.Executor
Imports
java.util.Collection, .List, .Timer, .TimerTask, java.util.concurrent.Callable, .ExecutionException, .Executor, .ExecutorService, .Executors, .Future, .TimeUnit, org.jspecify.annotations.NonNull, org.slf4j.Logger, .LoggerFactory

Responsible for managing of all threads (except GUI threads) in JabRef.

GUI background tasks should run in `org.jabref.gui.util.UiTaskExecutor``

This is a wrapper around ExecutorService

Offers both high-priority and low-priority thread pools.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final String
private final ExecutorService
public static final HeadlessExecutorService
private static final Logger
private static final String
private final ExecutorService
private final Timer

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
execute(@NonNull Runnable command)

Implements java.util.concurrent.Executor.execute.

Executes the given command at some time in the future.

public <T> Future<T>

Returns:

A Future object that provides the returning value.
execute
(@NonNull Callable<T>
The task to execute.
command
)

Executes a callable task that provides a return value after the calculation is done.

public <T> List<Future<T>>

Returns:

A List of Future objects that provide the returning values.
executeAll
(@NonNull Collection<Callable<T>>
The tasks to execute
tasks
)

Executes a collection of callable tasks and returns a List of the resulting Future objects after the calculation is done.

public <T> List<Future<T>>
executeAll(@NonNull Collection<Callable<T>> tasks, int timeout, TimeUnit timeUnit)

public void
public Future<?>
executeInterruptableTask(final Runnable runnable, String taskName)

public void
public static void
gracefullyShutdown(String name, ExecutorService executorService, int timeoutInSeconds)

Shuts down the provided executor service by first trying a normal shutdown, then waiting for the shutdown and then forcibly shutting it down.

public void
shutdownEverything()

Shuts everything down.

public void
submit(TimerTask timerTask, long millisecondsDelay)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EXECUTOR_NAMEback to summary
private static final String EXECUTOR_NAME
executorServiceback to summary
private final ExecutorService executorService
INSTANCEback to summary
public static final HeadlessExecutorService INSTANCE
LOGGERback to summary
private static final Logger LOGGER
LOW_PRIORITY_EXECUTOR_NAMEback to summary
private static final String LOW_PRIORITY_EXECUTOR_NAME
lowPriorityExecutorServiceback to summary
private final ExecutorService lowPriorityExecutorService
timerback to summary
private final Timer timer

Constructor Detail

HeadlessExecutorServiceback to summary
private HeadlessExecutorService()

Method Detail

executeback to summary
public void execute(@NonNull Runnable command)

Implements java.util.concurrent.Executor.execute.

Doc from java.util.concurrent.Executor.execute.

Executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the Executor implementation.

executeback to summary
public <T> Future<T> execute(@NonNull Callable<T> command)

Executes a callable task that provides a return value after the calculation is done.

Parameters
command:@NonNull Callable<T>

The task to execute.

Returns:Future<T>

A Future object that provides the returning value.

executeAllback to summary
public <T> List<Future<T>> executeAll(@NonNull Collection<Callable<T>> tasks)

Executes a collection of callable tasks and returns a List of the resulting Future objects after the calculation is done.

Parameters
tasks:@NonNull Collection<Callable<T>>

The tasks to execute

Returns:List<Future<T>>

A List of Future objects that provide the returning values.

executeAllback to summary
public <T> List<Future<T>> executeAll(@NonNull Collection<Callable<T>> tasks, int timeout, TimeUnit timeUnit)
executeAndWaitback to summary
public void executeAndWait(@NonNull Runnable command)
executeInterruptableTaskback to summary
public Future<?> executeInterruptableTask(final Runnable runnable, String taskName)
executeInterruptableTaskAndWaitback to summary
public void executeInterruptableTaskAndWait(@NonNull Runnable runnable)
gracefullyShutdownback to summary
public static void gracefullyShutdown(String name, ExecutorService executorService, int timeoutInSeconds)

Shuts down the provided executor service by first trying a normal shutdown, then waiting for the shutdown and then forcibly shutting it down. Returns if the status of the shut down is known.

shutdownEverythingback to summary
public void shutdownEverything()

Shuts everything down. After termination, this method returns.

submitback to summary
public void submit(TimerTask timerTask, long millisecondsDelay)
org.jabref.logic.util back to summary

private Class HeadlessExecutorService.NamedRunnable

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Field Summary

Modifier and TypeField and Description
private final String
private final Runnable

Constructor Summary

AccessConstructor and Description
private
NamedRunnable(String name, Runnable runnable)

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nameback to summary
private final String name
taskback to summary
private final Runnable task

Constructor Detail

NamedRunnableback to summary
private NamedRunnable(String name, Runnable runnable)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override