|
|||||||||||
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
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
|
Field Summary |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Method Summary | |
static void |
addJob(UICSimpleAction action,
Object source)
add a job to the queue to be executed at a undefined date in the future. |
static void |
addJob(UICSimpleAction action,
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. |
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, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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, java.lang.Object, boolean)
public static void addJob(UICSimpleAction action, 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 void addJob(UICSimpleAction action, 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()
public void lock()
IllegalStateException
- if the thread is already locked; which implies a concurrency issue.getJobsList()
,
unlock()
,
UICSimpleAction.setExecutionPolity(uic.model.UICSimpleAction.ExecutePolicy)
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.setExecutionPolity(uic.model.UICSimpleAction.ExecutePolicy)
public int size()
public void unlock()
getJobsList()
,
lock()
,
UICSimpleAction.setExecutionPolity(uic.model.UICSimpleAction.ExecutePolicy)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |