|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.util.Monitor
public class Monitor
Monitor is a convenient class that is useful to communicate between threads by exchanging information through this Monitor. The Monitor contains several generically useful members which can be accessed thread-savely to provide for different needs. There is also the availability of a custom call-back function for several purposes.
| Field Summary | |
|---|---|
boolean |
test
|
Stopwatch |
timer
initialized as running during instanciation |
| Constructor Summary | |
|---|---|
Monitor()
|
|
Monitor(boolean enable,
int size,
Runnable task)
initializes the arrays in this instance with n elements to store/exchange data; task's run() method can be called with runTask() |
|
Monitor(int size)
|
|
| Method Summary | |
|---|---|
void |
disable()
|
boolean |
disabled()
|
void |
disableLater(long milliseconds)
This function starts a separate Thread that will disable this Monitor in the given time in milliseconds automatically. |
void |
done()
the effect can only be reversed through reInitialize() |
void |
enable()
enable() sets the Monitor to be enabled() and also interrupts threads scheduled through disableLater() |
boolean |
enabled()
|
int |
getMax()
|
String |
getMessage()
|
int |
getMin()
|
int |
getNumber()
|
int |
getNumber(int i)
|
Object |
getObject()
|
Object |
getObject(int i)
|
int |
getSize()
returns the length of the monitor's arrays initialized by the constructor or reInitialize() |
Runnable |
getTask()
|
Stopwatch |
getTimer(int i)
|
void |
increment()
|
void |
increment(int i)
|
boolean |
isDone()
|
void |
reInitialize(boolean enable,
int size,
Runnable task)
all objects and arrays are re-initialized as if newly constructed; only the timer is maintained |
void |
runTask()
lets the Thread that uses the Monitor perform a synchronous custom task that completes before the current thread continues. |
void |
setMax(int max)
|
void |
setMessage(String msg)
|
void |
setMin(int min)
|
void |
setNumber(int number)
|
void |
setNumber(int i,
int number)
|
void |
setObject(int i,
Object obj)
|
void |
setObject(Object obj)
|
void |
setTask(Runnable task)
|
boolean |
test(int i)
|
void |
test(int i,
boolean t)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final Stopwatch timer
public volatile boolean test
| Constructor Detail |
|---|
public Monitor()
public Monitor(int size)
public Monitor(boolean enable,
int size,
Runnable task)
runTask()| Method Detail |
|---|
public void reInitialize(boolean enable,
int size,
Runnable task)
public void disableLater(long milliseconds)
public void enable()
public void disable()
public boolean enabled()
public boolean disabled()
public boolean isDone()
public void done()
public void increment()
public void increment(int i)
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsExceptionpublic int getNumber()
public int getNumber(int i)
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsExceptionpublic int getMin()
public int getMax()
public void setMin(int min)
public void setMax(int max)
public void setNumber(int number)
public void setNumber(int i,
int number)
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsExceptionpublic void setObject(Object obj)
public void setObject(int i,
Object obj)
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsExceptionpublic void setMessage(String msg)
public Object getObject()
public Object getObject(int i)
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsExceptionpublic String getMessage()
public Stopwatch getTimer(int i)
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsExceptionpublic void setTask(Runnable task)
public Runnable getTask()
public void test(int i,
boolean t)
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException
public boolean test(int i)
throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsExceptionpublic int getSize()
public void runTask()
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||