Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
Worker()
Creates a new worker with an default infinite idle timeout.
|
Worker(int sleeptime)
Creates a new worker.
|
Modifier and Type | Method and Description |
---|---|
void |
finish()
Kills the worker immediately.
|
Runnable |
getWorkload()
Returns the workload object.
|
boolean |
isAvailable()
Checks whether this worker has some work to do.
|
boolean |
isFinish()
Checks whether this worker has received the signal to finish and die.
|
void |
run()
If a workload is set, process it.
|
void |
setWorkload(Runnable r)
Set the next workload for this worker.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public Worker(int sleeptime)
sleeptime
- the time this worker sleeps until he checks for new work.public Worker()
public void setWorkload(Runnable r)
r
- the next workload for the worker.IllegalStateException
- if the worker is not idle.public Runnable getWorkload()
public void finish()
public boolean isAvailable()
public void run()
public boolean isFinish()
Copyright © 2017 Hitachi Vantara. All rights reserved.