public class ThreadPool2
extends java.lang.Object
implements java.util.concurrent.Executor
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
THREAD_FULL_EVENT |
Constructor and Description |
---|
ThreadPool2() |
ThreadPool2(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
void |
clearIdleThreads()
interrupts all the idle threads.
|
void |
close() |
void |
closeEnvironment(java.lang.ClassLoader env)
Resets the thread pool, letting old threads drain.
|
void |
execute(java.lang.Runnable task) |
static ThreadPool2 |
getCurrent() |
int |
getFreeThreadCount()
Returns the free thread count.
|
int |
getIdleMax()
Returns the thread idle max.
|
int |
getIdleMin()
Gets the minimum number of idle threads.
|
long |
getIdleTimeout()
Returns the idle timeout.
|
int |
getPriorityIdleMin() |
int |
getThreadActiveCount()
Returns the active thread count.
|
int |
getThreadCount()
Returns the total thread count.
|
long |
getThreadCreateCountTotal()
Returns the total created thread count.
|
int |
getThreadIdleCount()
Returns the idle thread count.
|
int |
getThreadMax()
Gets the maximum number of threads.
|
long |
getThreadOverflowCountTotal()
Returns the total created overflow thread count.
|
int |
getThreadPriorityQueueSize()
Returns priority queue size
|
int |
getThreadStartingCount()
Returns the starting thread count.
|
int |
getThreadTaskQueueSize()
Returns task queue size
|
int |
getThreadWaitCount()
Returns the waiting thread count.
|
void |
reset()
Resets the thread pool, letting old threads drain.
|
boolean |
schedule(java.lang.Runnable task)
Schedules a new task.
|
boolean |
schedule(java.lang.Runnable task,
java.lang.ClassLoader loader)
Schedules a new task.
|
boolean |
schedule(java.lang.Runnable task,
long timeout)
Adds a new task.
|
protected boolean |
scheduleImpl(java.lang.Runnable task,
java.lang.ClassLoader loader,
long expireTime,
boolean isPriority,
boolean isQueueIfFull,
boolean isWakeScheduler)
main scheduling implementation class.
|
void |
schedulePriority(java.lang.Runnable task)
Adds a new task.
|
void |
scheduleUnpark(java.lang.Thread thread) |
protected void |
setAsGlobal(ThreadPool2 pool) |
void |
setIdleMax(int idleMax)
Returns the thread idle max.
|
void |
setIdleMin(int min)
Sets the minimum number of idle threads.
|
void |
setIdleTimeout(long timeout)
Sets the idle timeout
|
void |
setPriorityIdleMin(int min)
Sets the minimum number of free threads reserved for priority tasks.
|
void |
setThreadMax(int max)
Sets the maximum number of threads.
|
void |
setThrottleLimit(int limit)
Sets the throttle limit.
|
void |
setThrottlePeriod(long period)
Sets the throttle period.
|
void |
setThrottleSleepTime(long period)
Sets the throttle sleep time.
|
void |
start() |
boolean |
start(java.lang.Runnable task)
Adds a new task.
|
boolean |
start(java.lang.Runnable task,
long timeout)
Adds a new task.
|
void |
startPriority(java.lang.Runnable task)
Adds a new task.
|
boolean |
startPriority(java.lang.Runnable task,
long timeout)
Adds a new task.
|
boolean |
submitNoWake(java.lang.Runnable task)
Submit a task, but do not wake the scheduler
|
boolean |
submitNoWake(java.lang.Runnable task,
java.lang.ClassLoader loader)
Submit a task, but do not wake the scheduler
|
java.lang.String |
toString() |
void |
wakeScheduler() |
public static final java.lang.String THREAD_FULL_EVENT
public ThreadPool2()
public ThreadPool2(java.lang.String name)
public static ThreadPool2 getCurrent()
protected void setAsGlobal(ThreadPool2 pool)
public void setThreadMax(int max)
public int getThreadMax()
public void setIdleMin(int min)
public int getIdleMin()
public int getIdleMax()
public void setIdleMax(int idleMax)
public void setPriorityIdleMin(int min)
public int getPriorityIdleMin()
public void setIdleTimeout(long timeout)
public long getIdleTimeout()
public void setThrottlePeriod(long period)
public void setThrottleLimit(int limit)
public void setThrottleSleepTime(long period)
public int getThreadCount()
public int getThreadActiveCount()
public int getThreadStartingCount()
public int getThreadIdleCount()
public int getThreadWaitCount()
public int getFreeThreadCount()
public long getThreadCreateCountTotal()
public long getThreadOverflowCountTotal()
public int getThreadPriorityQueueSize()
public int getThreadTaskQueueSize()
public void start()
public void execute(java.lang.Runnable task)
execute
in interface java.util.concurrent.Executor
public boolean schedule(java.lang.Runnable task)
public boolean schedule(java.lang.Runnable task, java.lang.ClassLoader loader)
public boolean schedule(java.lang.Runnable task, long timeout)
public void schedulePriority(java.lang.Runnable task)
public boolean start(java.lang.Runnable task)
public boolean start(java.lang.Runnable task, long timeout)
public void startPriority(java.lang.Runnable task)
public boolean startPriority(java.lang.Runnable task, long timeout)
public boolean submitNoWake(java.lang.Runnable task)
public boolean submitNoWake(java.lang.Runnable task, java.lang.ClassLoader loader)
protected boolean scheduleImpl(java.lang.Runnable task, java.lang.ClassLoader loader, long expireTime, boolean isPriority, boolean isQueueIfFull, boolean isWakeScheduler)
public void wakeScheduler()
public final void scheduleUnpark(java.lang.Thread thread)
public void reset()
public void closeEnvironment(java.lang.ClassLoader env)
public void clearIdleThreads()
public void close()
public java.lang.String toString()
toString
in class java.lang.Object