|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread uic.model.WorkerThread
public class WorkerThread
This is a helper class for the Actions framework. The basic job of this class is to queue and execute jobs added to it via the action framework.
The long explenation is (still very short) that in Swing you need to seperate long running actions that started due to button pressed into a separate thread to limit freezing GUIs. We do this automatically in the ActionFactory by means of placing the jobs that need to be done in a queue to be executed as soon as possible. The placing itself does not take time, allowing the repainting to continue on its way.
This class is the one that queues the jobs and is called from the UICSimpleAction and extending classes.
Nested Class Summary | |
---|---|
static class |
WorkerThread.Job
|
class |
WorkerThread.Worker
|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Method Summary | |
---|---|
static WorkerThread.Job |
addJob(UICSimpleAction action)
|
static WorkerThread.Job |
addJob(UICSimpleAction action,
Object[] arguments,
Object source)
add a job to the queue to be executed at a undefined date in the future. |
static WorkerThread.Job |
addJob(UICSimpleAction action,
Object[] arguments,
Object source,
boolean enable)
add a job to the queue to be executed at a undefined date in the future. |
static WorkerThread |
getInstance()
Get the sole instance of the worker thread; if none exist create and start it. |
List |
getJobsList()
Returns the jobs list which can be altered inline for advanced scheduling policies. |
void |
lock()
Locks the worker thread from executing new jobs. |
static void |
markLocking()
Widgets should call this method if they lock for a long period of time. |
void |
run()
Never ending thread that executed job after job, waiting for more in beteen. |
int |
size()
|
void |
unlock()
Unlock the queue to resume executing jobs. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, 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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static WorkerThread getInstance()
addJob(uic.model.UICSimpleAction)
public static WorkerThread.Job addJob(UICSimpleAction action)
public static WorkerThread.Job addJob(UICSimpleAction action, Object[] arguments, Object source, boolean enable)
action
- the action that holdes the target method that should be invoked.source
- the source of the action, if this comes from an ActionEvent its most
likely the getSource.enable
- the enabled-state to set the action to after completing the job.public static WorkerThread.Job addJob(UICSimpleAction action, Object[] arguments, Object source)
action
- the action that holdes the target method that should be invoked.source
- the source of the action, if this comes from an ActionEvent its most
likely the getSource.public void run()
run
in interface Runnable
run
in class Thread
public void lock()
IllegalStateException
- if the thread is already locked; which implies a concurrency issue.getJobsList()
,
unlock()
,
UICSimpleAction.setExecutionPolicy(uic.model.UICSimpleAction.ExecutePolicy)
public static void markLocking()
The very small amount of cases this applies to should call this method just prior to the thread becoming locked, and call it from the calling thread (which would be the workerthread), not the AWTEventThread.
public List getJobsList()
Job
.
Altering the List by removing or moving around the job objects is allowed; adding
other objects is not.
IllegalStateException
- if the queue has not been locked before.lock()
,
unlock()
,
UICSimpleAction.setExecutionPolicy(uic.model.UICSimpleAction.ExecutePolicy)
public int size()
public void unlock()
getJobsList()
,
lock()
,
UICSimpleAction.setExecutionPolicy(uic.model.UICSimpleAction.ExecutePolicy)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |