public final class TaskManager extends Object
TaskGroups.
You can register, reconfigure and shutdown separate TaskGroups.
Usig TaskGroup identifier you can execute Runnable or Callable tasks.TaskGroup,
TaskException| Modifier and Type | Field and Description |
|---|---|
static String |
COMPUTATION
Identifier of predefined
TaskGroup for computation requests. |
static String |
FILE_SYSTEM
Identifier of predefined
TaskGroup for file system requests. |
static String |
REMOTE_REQUEST
Identifier of predefined
TaskGroup for remote requests. |
| Constructor and Description |
|---|
TaskManager() |
| Modifier and Type | Method and Description |
|---|---|
static void |
configureGroup(TaskGroup group)
Configures existing
TaskGroup. |
static <V> Future<V> |
execute(String groupId,
Callable<V> callable)
|
static Future<?> |
execute(String groupId,
Runnable runnable)
|
static boolean |
exists(String groupId)
Returns whether or not
TaskGroup with the specified identifier already exists. |
static boolean |
exists(TaskGroup group)
Returns whether or not specified
TaskGroup already exists. |
static TaskGroup |
getGroup(String groupId)
Returns
TaskGroup with the specified identifier. |
static void |
initialize()
Initializes
TaskManager settings. |
static void |
registerGroup(TaskGroup group)
Registers new
TaskGroup. |
static void |
shutdown(String groupId)
Shutdowns
TaskGroup with the specified identifier after finishing all remaining submitted tasks. |
static void |
shutdownNow(String groupId)
Shutdowns
TaskGroup with the specified identifier without finishing any of remaining submitted tasks. |
public static final String FILE_SYSTEM
TaskGroup for file system requests.
By default it uses maximum 4 threads and DaemonThreadFactory.
It can be configured through providing new ThreadGroup with same identifier in configureGroup(TaskGroup).public static final String REMOTE_REQUEST
TaskGroup for remote requests.
By default it uses maximum 4 threads and DaemonThreadFactory.
It can be configured through providing new ThreadGroup with same identifier in configureGroup(TaskGroup).public static final String COMPUTATION
TaskGroup for computation requests.
By default it uses maximum 8 threads and DaemonThreadFactory.
It can be configured through providing new ThreadGroup with same identifier in configureGroup(TaskGroup).public static void initialize()
TaskManager settings.public static boolean exists(@NotNull TaskGroup group)
TaskGroup already exists.public static boolean exists(@NotNull String groupId)
TaskGroup with the specified identifier already exists.@NotNull public static TaskGroup getGroup(@NotNull String groupId)
TaskGroup with the specified identifier.
Throws TaskException if such TaskGroup is not yet registered.public static void registerGroup(@NotNull TaskGroup group)
group - TaskGroup to registerpublic static void configureGroup(@NotNull TaskGroup group)
group - TaskGroup to configure@NotNull public static Future<?> execute(@NotNull String groupId, @NotNull Runnable runnable)
@NotNull public static <V> Future<V> execute(@NotNull String groupId, @NotNull Callable<V> callable)
public static void shutdown(@NotNull String groupId)
TaskGroup with the specified identifier after finishing all remaining submitted tasks.groupId - identifier of TaskGroup to shutdownCopyright © 2020. All rights reserved.