public class TaskGroup extends Object implements Identifiable
Thread groups.
You can register and shutdown TaskGroups within TaskManager at will.TaskManager| Modifier and Type | Field and Description |
|---|---|
protected ExecutorService |
executorService
ExecutorService used for executing tasks. |
protected String |
id
This
TaskGroup identifier. |
protected int |
maxThreadsCount
|
protected ThreadFactory |
threadFactory
ThreadFactory used to spawn Threads for executing tasks. |
| Constructor and Description |
|---|
TaskGroup(String id)
Constructs new
TaskGroup. |
TaskGroup(String id,
int maxThreadsCount)
Constructs new
TaskGroup. |
TaskGroup(String id,
ThreadFactory threadFactory)
Constructs new
TaskGroup. |
TaskGroup(String id,
ThreadFactory threadFactory,
int maxThreadsCount)
Constructs new
TaskGroup. |
| Modifier and Type | Method and Description |
|---|---|
<V> Future<V> |
execute(Callable<V> callable)
Executes specified
Callable. |
Future<?> |
execute(Runnable runnable)
Executes specified
Runnable. |
protected ExecutorService |
executorService()
Returns
ExecutorService that can be used to execute tasks according to this TaskGroup settings. |
String |
getId()
Returns unique object identifier.
|
int |
hashCode() |
void |
shutdown()
Shutdowns this
TaskGroup after finishing all remaining submitted tasks. |
void |
shutdownNow()
Shutdowns this
TaskGroup without finishing any of remaining submitted tasks. |
@NotNull protected final ThreadFactory threadFactory
ThreadFactory used to spawn Threads for executing tasks.protected final int maxThreadsCount
@Nullable protected ExecutorService executorService
ExecutorService used for executing tasks.public TaskGroup(@NotNull String id)
TaskGroup.id - this TaskGroup identifierpublic TaskGroup(@NotNull String id, @NotNull ThreadFactory threadFactory)
TaskGroup.id - this TaskGroup identifierthreadFactory - ThreadFactory used to spawn Threads for executing taskspublic TaskGroup(@NotNull String id, @NotNull ThreadFactory threadFactory, int maxThreadsCount)
TaskGroup.id - this TaskGroup identifierthreadFactory - ThreadFactory used to spawn Threads for executing tasksmaxThreadsCount - maximum parallel Threads count in this TaskGroup@NotNull public String getId()
IdentifiableNotNull in futuregetId in interface Identifiablepublic void shutdown()
TaskGroup after finishing all remaining submitted tasks.public void shutdownNow()
TaskGroup without finishing any of remaining submitted tasks.@NotNull protected ExecutorService executorService()
ExecutorService that can be used to execute tasks according to this TaskGroup settings.
In case ExecutorService doesn't exist or was shutdown it will be recreated.ExecutorService that can be used to execute tasks according to this TaskGroup settingsCopyright © 2020. All rights reserved.