@Module public abstract class AbstractThreadLauncher2 extends AbstractTaskWorker2
Modifier | Constructor and Description |
---|---|
protected |
AbstractThreadLauncher2() |
protected |
AbstractThreadLauncher2(java.lang.ClassLoader loader) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected boolean |
doStart()
Checks if the launcher should start another thread.
|
long |
getCreateCountTotal() |
int |
getIdleCount() |
int |
getIdleMax()
Gets the maximum number of idle threads.
|
int |
getIdleMin()
Gets the minimum number of idle threads.
|
long |
getIdleTimeout()
Returns the idle timeout.
|
int |
getStartingCount() |
int |
getThreadCount() |
int |
getThreadMax()
Gets the maximum number of threads.
|
protected boolean |
isEnable() |
boolean |
isIdleExpire()
Returns true if the thread should expire instead of going to the idle state.
|
boolean |
isIdleLow() |
boolean |
isIdleOverflow()
Start the idle if the child idle is less than idle max.
|
protected boolean |
isIdleTooLow(int startingCount) |
boolean |
isThreadHigh() |
boolean |
isThreadMax() |
protected abstract void |
launchChildThread(int id) |
void |
onChildIdleBegin()
Called by the thread before going into the idle state.
|
void |
onChildIdleEnd()
Called by the thread after exiting the idle state.
|
void |
onChildThreadLaunchBegin()
Callback from the launched thread's run().
|
void |
onChildThreadLaunchEnd()
Callback from the launched thread's run().
|
void |
onChildThreadResumeBegin()
Start housekeeping for a child thread managed by the launcher's
housekeeping, but not spawned by the launcher itself, e.g.
|
void |
onChildThreadResumeEnd()
End housekeeping for a child thread managed by the launcher's
housekeeping, but not spawned by the launcher itself, e.g.
|
protected void |
onThreadMax() |
protected void |
onThrottle(java.lang.String msg) |
long |
runTask() |
void |
setIdleMax(int max)
Sets the maximum number of idle threads.
|
void |
setIdleMin(int min)
Sets the minimum number of idle threads.
|
void |
setIdleTimeout(long timeout)
Sets the idle timeout
|
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() |
protected void |
update() |
protected void |
updateIdleExpireTime(long now)
updates the thread idle expire time.
|
protected void |
updateThrottle()
Throttle the thread creation, so only 100 threads/sec (default) can
be created.
|
getClassLoader, getCurrentTimeActual, getState, getThreadName, isClosed, isPermanent, isRetry, isTaskActive, isWeakClose, onThreadComplete, onThreadStart, run, setWorkerIdleTimeout, startWorkerThread, toString, unpark, wake
protected AbstractThreadLauncher2()
protected AbstractThreadLauncher2(java.lang.ClassLoader loader)
protected abstract void launchChildThread(int id)
public void setThreadMax(int max)
public int getThreadMax()
public void setIdleMin(int min)
public int getIdleMin()
public void setIdleMax(int max)
public int getIdleMax()
public void setIdleTimeout(long timeout)
public long getIdleTimeout()
protected boolean isEnable()
public void setThrottlePeriod(long period)
public void setThrottleLimit(int limit)
public void setThrottleSleepTime(long period)
public void start()
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class AbstractTaskWorker2
public boolean isThreadMax()
public boolean isThreadHigh()
public void onChildThreadLaunchBegin()
public void onChildThreadLaunchEnd()
public void onChildThreadResumeBegin()
public void onChildThreadResumeEnd()
public boolean isIdleExpire()
public final boolean isIdleLow()
public boolean isIdleOverflow()
public void onChildIdleBegin()
public void onChildIdleEnd()
protected void updateIdleExpireTime(long now)
protected boolean doStart()
protected boolean isIdleTooLow(int startingCount)
protected void update()
protected void updateThrottle()
protected void onThreadMax()
protected void onThrottle(java.lang.String msg)
public int getThreadCount()
public int getIdleCount()
public int getStartingCount()
public long getCreateCountTotal()
public long runTask()
runTask
in class AbstractTaskWorker2