|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--se.lth.cs.realtime.RTThread | +--se.lth.cs.realtime.CyclicThread
This class models a real-time thread with cyclic behaviour.
Such a thread loops performing an action and waiting for some time to pass. The action performed and the waiting policy are not specified in this class, which is so declared abstract.
PeriodicThread
Fields inherited from class se.lth.cs.realtime.RTThread |
defaultEventBufferSize, listenerList, mailbox, MAX_PRIORITY, MIN_PRIORITY |
Constructor Summary | |
CyclicThread()
Allocates a new CyclicThread . |
|
CyclicThread(RTThreadGroup group)
Allocates a new CyclicThread . |
|
CyclicThread(RTThreadGroup group,
java.lang.String name)
Allocates a new CyclicThread . |
|
CyclicThread(RTThreadGroup group,
java.lang.String name,
boolean privateQueue)
Allocates a new CyclicThread . |
|
CyclicThread(java.lang.String name)
Allocates a new CyclicThread . |
Method Summary | |
boolean |
isSuspended()
Checks whether this thread is suspended. |
protected void |
onResuming()
Perform any adjustments required when resuming a thread. |
protected abstract void |
perform()
Defines the action performed by this thread. |
void |
resume()
Asks a suspended thread to resume execution. |
void |
run()
Defines the behaviour of a cyclic thread. |
void |
stop()
Asks this thread to stop its execution. |
void |
suspend()
Asks the thread to suspend its execution. |
java.lang.String |
toString()
Returns a string representation of this thread, including the thread's name and priority. |
protected abstract void |
waitToPerform()
Defines the waiting policy of this thread. |
Methods inherited from class se.lth.cs.realtime.RTThread |
currentRTThread, dumpStack, getName, getPriority, getRTThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, putEvent, setDaemon, setName, setPriority, sleep, sleep, sleepUntil, start, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public CyclicThread()
CyclicThread
.
Equivalent to CyclicThread(null, null, true)
.
CyclicThread(RTThreadGroup, java.lang.String, boolean)
public CyclicThread(java.lang.String name)
CyclicThread
.
Equivalent to CyclicThread(null, name, true)
.
name
- this thread's name.CyclicThread(RTThreadGroup, java.lang.String, boolean)
public CyclicThread(RTThreadGroup group)
CyclicThread
.
Equivalent to CyclicThread(group, null, true)
.
group
- this thread's RTThreadGroup
.CyclicThread(RTThreadGroup, java.lang.String, boolean)
public CyclicThread(RTThreadGroup group, java.lang.String name)
CyclicThread
.
Equivalent to CyclicThread(group, name, true)
.
group
- this thread's RTThreadGroup
.name
- this thread's name.CyclicThread(RTThreadGroup, java.lang.String, boolean)
public CyclicThread(RTThreadGroup group, java.lang.String name, boolean privateQueue)
CyclicThread
.
Also sets whether this thread should use a private queue when waiting to be resumed. Using a private queue imposes space overhead, but guarantees better time predictability.
group
- this thread's RTThreadGroup
.name
- this thread's name.privateQueue
- whether this thread should use a private queue.RTThread.RTThread(RTThreadGroup, java.lang.String)
Method Detail |
protected abstract void perform()
protected abstract void waitToPerform() throws java.lang.InterruptedException
perform
.
The implementor is given the possibility of throwing or passing an
InterruptedException
, which may cause the acknowledgment
of a suspend
or a stop
.
java.lang.InterruptedException
- if another thread interrupts this thread.public final void suspend()
perform
, to prevent
deadlocks. It is possible to suspend a thread which has not yet been started.
Calling suspend
on a suspended thread has no effect.public boolean isSuspended()
onResuming
is called.suspend()
public final void resume()
onResuming
will be called.
It is possible to resume a thread which has not yet been started,
to undo a previous call to suspend
..
If the thread is not suspended, resume
has no effect.suspend()
public void stop()
protected void onResuming()
onResuming
does nothing.resume()
public final void run()
1. if has been asked to stop, it stops.
2. if has been asked to suspend itself, waits to be resumed
and then calls onResuming
.
3. calls waitToPerform
(if an InterruptedException
is caught, it goes to 1).
4. calls perform
.
5. goes to 1.
run
in interface java.lang.Runnable
run
in class RTThread
RTThread.run()
public java.lang.String toString()
toString
in class RTThread
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |