sjt.mgmt
Class SimpleWorkManager
java.lang.Object
|
+--sjt.mgmt.SimpleWorkManager
- All Implemented Interfaces:
- WorkManager
- public class SimpleWorkManager
- extends java.lang.Object
- implements WorkManager
WorkManager is the first implementation of all SJT.Mgmt threading solutions. It is expected
that other parties may wish to implement better or different solutions other than the ones
provided with this library.
- Since:
- SJT 0.1
|
Constructor Summary |
SimpleWorkManager(java.lang.String name,
int size)
Creates new SimpleWorkManager, construct an empty WorkGroup. |
|
Method Summary |
void |
addBlockingWork(java.lang.Runnable work)
Add a Runnable object to the work list, notify waiting threads of new work,
and block until run method exits |
void |
addBlockingWork(java.lang.Runnable work,
java.lang.Object lock)
Add a Runnable object to the work list, notify waiting threads of new work,
and block on provided lock object until run method exits. |
void |
addWork(java.lang.Runnable work)
Add a Runnable object to the work list, and notify waiting threads of new work. |
void |
addWork(java.lang.Runnable work,
java.lang.Object lock)
Add a Runnable object to the work list, and notify waiting threads of new work. |
void |
destroy()
Set resources to null once work list is null. |
protected void |
finalize()
Override finalize method with one that calls destroy. |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SimpleWorkManager
public SimpleWorkManager(java.lang.String name,
int size)
- Creates new SimpleWorkManager, construct an empty WorkGroup.
- Parameters:
name - identifier for thread manager, also passed to all working threads.size - size of the working threads pool.
addWork
public void addWork(java.lang.Runnable work)
- Add a Runnable object to the work list, and notify waiting threads of new work.
- Specified by:
addWork in interface WorkManager
- Parameters:
work - The Runnable instance containing executable code.- Throws:
IllegalStateException - if not accepting new work.
addWork
public void addWork(java.lang.Runnable work,
java.lang.Object lock)
- Add a Runnable object to the work list, and notify waiting threads of new work.
- Specified by:
addWork in interface WorkManager
- Parameters:
work - The Runnable instance containing executable code.- Throws:
IllegalStateException - if not accepting new work.
addBlockingWork
public void addBlockingWork(java.lang.Runnable work)
throws java.lang.InterruptedException
- Add a Runnable object to the work list, notify waiting threads of new work,
and block until run method exits
- Specified by:
addBlockingWork in interface WorkManager
- Parameters:
work - The Runnable instance containing executable code.- Throws:
IllegalStateException - if not accepting new work.java.lang.InterruptedException - if thread is interrupted.
addBlockingWork
public void addBlockingWork(java.lang.Runnable work,
java.lang.Object lock)
throws java.lang.InterruptedException
- Add a Runnable object to the work list, notify waiting threads of new work,
and block on provided lock object until run method exits.
- Specified by:
addBlockingWork in interface WorkManager
- Parameters:
work - The Runnable instance containing executable code.- Throws:
IllegalStateException - if not accepting new work.java.lang.InterruptedException - if thread is interrupted.
destroy
public void destroy()
- Set resources to null once work list is null.
- Specified by:
destroy in interface WorkManager
finalize
protected void finalize()
- Override finalize method with one that calls destroy.
- Overrides:
finalize in class java.lang.Object