public class ThreadPoolTaskService extends Object implements TaskService
TaskService
implementation which makes use of a ThreadPoolExecutor
to execute
tasks on a number of background threads.Constructor and Description |
---|
ThreadPoolTaskService(String name) |
Modifier and Type | Method and Description |
---|---|
void |
addTaskListener(TaskListener l)
Add a listener to receive notifications about the activities of this task service.
|
int |
getActiveTaskCount() |
int |
getCorePoolSize() |
static ThreadPoolTaskService |
getDefault() |
TaskExecutor<Object> |
getExecutor()
Get a
TaskExecutor scoped for the current thread. |
<R> TaskExecutor<R> |
getExecutor(TaskScope<R> scope)
Create a
TaskExecutor for the given TaskScope . |
<R> TaskExecutor<R> |
getExecutor(TaskScope<R> scope,
int priority)
Create a
TaskExecutor for the given TaskScope . |
int |
getMaximumPoolSize() |
int |
getQueuedTaskCount() |
void |
removeTaskListener(TaskListener l)
Remove a listener previously installed to receive notifications about the activities of this task service.
|
void |
setCorePoolSize(int corePoolSize) |
static void |
setExecutorManager(ExecutorManager executorManager) |
void |
setMaximumPoolSize(int maximumPoolSize) |
void |
shutdown() |
static void |
shutdownDefault() |
public ThreadPoolTaskService(String name)
public static ThreadPoolTaskService getDefault()
public static void setExecutorManager(ExecutorManager executorManager)
public static void shutdownDefault()
public void addTaskListener(TaskListener l)
TaskService
addTaskListener
in interface TaskService
public int getActiveTaskCount()
public int getCorePoolSize()
ThreadPoolExecutor.getCorePoolSize()
public TaskExecutor<Object> getExecutor()
TaskExecutor
scoped for the current thread. If no scope for the current thread
exists, a new scope is created. The scope inherits the current thread's priority.getExecutor
in interface TaskService
public <R> TaskExecutor<R> getExecutor(TaskScope<R> scope)
TaskService
TaskExecutor
for the given TaskScope
. Tasks will be executed with the default priority.getExecutor
in interface TaskService
public <R> TaskExecutor<R> getExecutor(TaskScope<R> scope, int priority)
TaskService
TaskExecutor
for the given TaskScope
. Tasks will be executed with the given priority.getExecutor
in interface TaskService
public int getMaximumPoolSize()
ThreadPoolExecutor.getMaximumPoolSize()
public int getQueuedTaskCount()
public void removeTaskListener(TaskListener l)
TaskService
removeTaskListener
in interface TaskService
public void setCorePoolSize(int corePoolSize)
ThreadPoolExecutor.setCorePoolSize(int)
public void setMaximumPoolSize(int maximumPoolSize)
public void shutdown()
Copyright © 2024 levigo holding gmbh. All rights reserved.