public class Processor extends java.util.concurrent.ThreadPoolExecutor
Modifier and Type | Class and Description |
---|---|
static interface |
Processor.ProcessorEventListener
Deprecated.
Useless interface
|
java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_PROCESSING |
static int |
DEFAULT_MAX_WAITING |
static int |
MAX_PRIORITY
The maximum priority that a thread can have.
|
static int |
MIN_PRIORITY
The minimum priority that a thread can have.
|
static int |
NORM_PRIORITY
The default priority that is assigned to a thread.
|
Constructor and Description |
---|
Processor()
Create a new Processor with default number of maximum waiting and processing tasks.
|
Processor(int numThread)
Create a new Processor with specified number of processing thread.
|
Processor(int maxWaiting,
int numThread)
Create a new Processor with specified number of maximum waiting and processing tasks.
|
Processor(int maxWaiting,
int numThread,
int priority)
Create a new Processor with specified number of maximum waiting and processing tasks.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(Processor.ProcessorEventListener listener)
Deprecated.
Useless...
|
boolean |
addTask(java.lang.Runnable task)
Deprecated.
Use
submit(Runnable) instead. |
boolean |
addTask(java.lang.Runnable task,
boolean onEDT)
Deprecated.
Use
submit(Runnable) instead. |
boolean |
addTask(java.lang.Runnable task,
boolean onEDT,
int id)
Deprecated.
Use
submit(Runnable) instead. |
void |
execute(java.lang.Runnable task) |
void |
fireDoneEvent(icy.system.thread.Processor.FutureTaskAdapter<?> task)
Deprecated.
useless
|
java.lang.String |
getDefaultThreadName()
Deprecated.
Use
getThreadName() instead |
int |
getFreeSlotNumber()
Get the number of free slot in queue
|
int |
getPriority() |
java.lang.String |
getThreadName()
Return the thread name.
|
int |
getWaitingTasksCount()
Return the number of waiting task
|
int |
getWaitingTasksCount(java.util.concurrent.Callable<?> task)
Return the number of task waiting in queue for the specified Callable instance.
|
int |
getWaitingTasksCount(int id)
Deprecated.
Not anymore supported.
Use getWaitingTasksCount(Callable) or getWaitingTasksCount(Runnable) instead. |
int |
getWaitingTasksCount(java.lang.Runnable task)
Return the number of task waiting in queue for the specified Runnable instance.
|
boolean |
hasWaitingTasks()
Return true if we have at least one task waiting in queue
|
boolean |
hasWaitingTasks(java.util.concurrent.Callable<?> task)
Return true if we have at least one task in queue for the specified Callable instance.
|
boolean |
hasWaitingTasks(int id)
Deprecated.
|
boolean |
hasWaitingTasks(java.lang.Runnable task)
Return true if we have at least one task in queue for the specified Runnable instance.
|
boolean |
isFull()
Return true if queue is full
|
boolean |
isProcessing()
Return true if one or more process are executing or we still have waiting tasks.
|
boolean |
limitWaitingTask(int value)
Deprecated.
This method is useless.
|
void |
limitWaitingTask(int id,
int value)
Deprecated.
Not anymore supported !
|
void |
limitWaitingTask(java.lang.Runnable task,
int value)
Deprecated.
This method is useless.
|
boolean |
remove(java.lang.Runnable task) |
void |
removeAllWaitingTasks()
Clear all waiting tasks
|
boolean |
removeFirstWaitingTask(java.util.concurrent.Callable<?> task)
Remove first waiting task for the specified Callable instance.
|
boolean |
removeFirstWaitingTask(int id)
Deprecated.
Not anymore supported.
USe removeFirstWaitingTask(Runnable) or removeFirstWaitingTask(Callable) instead. |
boolean |
removeFirstWaitingTask(java.lang.Runnable task)
Remove first waiting task for the specified Runnable instance.
|
void |
removeListener(Processor.ProcessorEventListener listener)
Deprecated.
Useless...
|
boolean |
removeTask(java.lang.Runnable task)
Deprecated.
Use
removeFirstWaitingTask(Runnable) instead. |
boolean |
removeWaitingTasks(java.util.concurrent.Callable<?> task)
Remove all waiting tasks for the specified Callable instance.
|
boolean |
removeWaitingTasks(int id)
Deprecated.
|
boolean |
removeWaitingTasks(java.lang.Runnable task)
Remove all waiting tasks for the specified Runnable instance.
|
void |
setDefaultThreadName(java.lang.String defaultThreadName)
Deprecated.
Use
setThreadName(String) instead |
void |
setPriority(int priority) |
void |
setThreadName(java.lang.String defaultThreadName)
Set the wanted thread name.
|
void |
shutdownAndWait()
shutdown and wait current tasks completion
|
<T> java.util.concurrent.Future<T> |
submit(boolean handleException,
java.util.concurrent.Callable<T> task)
Submits a value-returning task for execution and returns a
Future representing the pending results of the task.
|
java.util.concurrent.Future<?> |
submit(boolean handleException,
java.lang.Runnable task)
Submits a Runnable task for execution and returns a Future
representing that task.
|
<T> java.util.concurrent.Future<T> |
submit(boolean handleException,
java.lang.Runnable task,
T result)
Submits a Runnable task for execution and returns a Future
representing that task.
|
<T> java.util.concurrent.Future<T> |
submit(java.util.concurrent.Callable<T> task) |
<T> java.util.concurrent.Future<T> |
submit(java.util.concurrent.Callable<T> task,
boolean onEDT)
Deprecated.
Use
submit(Callable) instead and ThreadUtil.invokeNow(..) where you need
it. |
java.util.concurrent.Future<?> |
submit(java.lang.Runnable task) |
java.util.concurrent.Future<?> |
submit(java.lang.Runnable task,
boolean onEDT)
Deprecated.
Use
submit(Runnable) instead and ThreadUtil.invokeNow(..) where you need
it. |
<T> java.util.concurrent.Future<T> |
submit(java.lang.Runnable task,
T result) |
<T> java.util.concurrent.Future<T> |
submit(java.lang.Runnable task,
T result,
boolean onEDT)
Deprecated.
Use
submit(Runnable, Object) instead and ThreadUtil.invokeNow(..) where
you
need it. |
void |
waitAll()
Wait for all tasks completion
|
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, toString
public static final int DEFAULT_MAX_WAITING
public static final int DEFAULT_MAX_PROCESSING
public static final int MIN_PRIORITY
public static final int NORM_PRIORITY
public static final int MAX_PRIORITY
public Processor(int maxWaiting, int numThread, int priority)
maxWaiting
- The length of waiting queue.numThread
- The maximum number of processing thread.priority
- Processor priorityProcessor.MIN_PRIORITY
Processor.NORM_PRIORITY
Processor.MAX_PRIORITY
public Processor(int maxWaiting, int numThread)
maxWaiting
- The length of waiting queue.numThread
- The maximum number of processing thread.public Processor(int numThread)
numThread
- The maximum number of processing thread.public Processor()
@Deprecated public boolean removeTask(java.lang.Runnable task)
removeFirstWaitingTask(Runnable)
instead.@Deprecated public boolean addTask(java.lang.Runnable task, boolean onEDT, int id)
submit(Runnable)
instead.@Deprecated public boolean addTask(java.lang.Runnable task, boolean onEDT)
submit(Runnable)
instead.@Deprecated public boolean addTask(java.lang.Runnable task)
submit(Runnable)
instead.public boolean remove(java.lang.Runnable task)
remove
in class java.util.concurrent.ThreadPoolExecutor
public void execute(java.lang.Runnable task)
execute
in interface java.util.concurrent.Executor
execute
in class java.util.concurrent.ThreadPoolExecutor
public java.util.concurrent.Future<?> submit(java.lang.Runnable task)
submit
in interface java.util.concurrent.ExecutorService
submit
in class java.util.concurrent.AbstractExecutorService
public <T> java.util.concurrent.Future<T> submit(java.lang.Runnable task, T result)
submit
in interface java.util.concurrent.ExecutorService
submit
in class java.util.concurrent.AbstractExecutorService
public <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task)
submit
in interface java.util.concurrent.ExecutorService
submit
in class java.util.concurrent.AbstractExecutorService
public java.util.concurrent.Future<?> submit(boolean handleException, java.lang.Runnable task)
handleException
- if set to true
then any occurring exception during the runnable
processing will be catch by IcyExceptionHandler
.task
- the task to submitjava.util.concurrent.RejectedExecutionException
- if the task cannot be
scheduled for executionjava.lang.NullPointerException
- if the task is nullpublic <T> java.util.concurrent.Future<T> submit(boolean handleException, java.lang.Runnable task, T result)
handleException
- if set to true
then any occurring exception during the runnable
processing will be catch by IcyExceptionHandler
.task
- the task to submitresult
- the result to returnjava.util.concurrent.RejectedExecutionException
- if the task cannot be
scheduled for executionjava.lang.NullPointerException
- if the task is nullpublic <T> java.util.concurrent.Future<T> submit(boolean handleException, java.util.concurrent.Callable<T> task)
If you would like to immediately block waiting for a task, you can use constructions of the form result = exec.submit(aCallable).get();
Note: The Executors
class includes a set of methods that can convert some other common closure-like
objects, for example, PrivilegedAction
to Callable
form so they can be submitted.
handleException
- if set to true
then any occurring exception during the runnable
processing will be catch by IcyExceptionHandler
.task
- the task to submitjava.util.concurrent.RejectedExecutionException
- if the task cannot be
scheduled for executionjava.lang.NullPointerException
- if the task is null@Deprecated public java.util.concurrent.Future<?> submit(java.lang.Runnable task, boolean onEDT)
submit(Runnable)
instead and ThreadUtil.invokeNow(..) where you need
it.@Deprecated public <T> java.util.concurrent.Future<T> submit(java.lang.Runnable task, T result, boolean onEDT)
submit(Runnable, Object)
instead and ThreadUtil.invokeNow(..) where
you
need it.@Deprecated public <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task, boolean onEDT)
submit(Callable)
instead and ThreadUtil.invokeNow(..) where you need
it.public boolean isProcessing()
public void waitAll()
public void shutdownAndWait()
public int getPriority()
public void setPriority(int priority)
priority
- the priority to set@Deprecated public java.lang.String getDefaultThreadName()
getThreadName()
instead@Deprecated public void setDefaultThreadName(java.lang.String defaultThreadName)
setThreadName(String)
insteadpublic java.lang.String getThreadName()
public void setThreadName(java.lang.String defaultThreadName)
public int getFreeSlotNumber()
public boolean isFull()
public int getWaitingTasksCount()
@Deprecated public int getWaitingTasksCount(int id)
getWaitingTasksCount(Callable)
or getWaitingTasksCount(Runnable)
instead.public int getWaitingTasksCount(java.lang.Runnable task)
public int getWaitingTasksCount(java.util.concurrent.Callable<?> task)
public boolean hasWaitingTasks()
@Deprecated public boolean hasWaitingTasks(int id)
hasWaitingTasks(Callable)
or hasWaitingTasks(Runnable)
instead.public boolean hasWaitingTasks(java.lang.Runnable task)
public boolean hasWaitingTasks(java.util.concurrent.Callable<?> task)
@Deprecated public boolean removeFirstWaitingTask(int id)
removeFirstWaitingTask(Runnable)
or removeFirstWaitingTask(Callable)
instead.public boolean removeFirstWaitingTask(java.lang.Runnable task)
public boolean removeFirstWaitingTask(java.util.concurrent.Callable<?> task)
@Deprecated public boolean removeWaitingTasks(int id)
removeWaitingTasks(Runnable)
or removeWaitingTasks(Callable)
instead.public boolean removeWaitingTasks(java.lang.Runnable task)
public boolean removeWaitingTasks(java.util.concurrent.Callable<?> task)
public void removeAllWaitingTasks()
@Deprecated public void limitWaitingTask(java.lang.Runnable task, int value)
@Deprecated public void limitWaitingTask(int id, int value)
@Deprecated public boolean limitWaitingTask(int value)
@Deprecated public void addListener(Processor.ProcessorEventListener listener)
@Deprecated public void removeListener(Processor.ProcessorEventListener listener)
@Deprecated public void fireDoneEvent(icy.system.thread.Processor.FutureTaskAdapter<?> task)