|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
se.lth.cs.realtime.JThread
Thread of concurrent execution according to the Java platform, but
extended with the facilities provided by the RTThread
class. Using the JThread
class, the event processing
facilities provided by the RTThread
is made available
in a subclass of java.lang.Thread
(which the
RTThread
is not). Another supported feature is the
method sleepUntil
. Preferably, threads are based on
the RTThread
which will run well on any Java platform
and enable real-time execution on a real-time (Java)
platform. However, for compatibility with existing software
(requiring java.lang.Thread
s) in cases when real-time
execution is known not to be needed, sub-classing
JThread
is useful. Thus, use RTThread
for
real-time threads and use JThread
for concurrent (Java)
threads.
License
,
Thread
,
RTThread
Field Summary |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
JThread()
Allocates a new JThread object with
a newly generated name in its father's ThreadGroup . |
|
JThread(java.lang.String name)
Allocates a new JThread object with
the specified name in its parent's ThreadGroup . |
|
JThread(java.lang.ThreadGroup group)
Allocates a new JThread object with a newly generated name
in the specified ThreadGroup . |
|
JThread(java.lang.ThreadGroup group,
java.lang.String name)
Allocates a new JThread object with
the specified name in the specified ThreadGroup . |
Method Summary | |
void |
addListener(RTEventListener subscriber)
Register subscriber as listener of application events
emitted from this thread object. |
RTEventDispatcher |
getDispatcher()
Obtain the object that internally stores the subscriptions of events, often referred to as the listener list. |
Environment |
getEnv()
Environments not implemented yet. |
Timebase |
getTimebase()
Time bases not implemented yet. |
RTEvent |
putEvent(RTEvent ev)
Put the time-stamped event in the input buffer of this thread. |
void |
run()
Default non-empty run method, first calling init ,
then calling perform while not interrupted, and finally calling
exit. |
static void |
sleep(long millis)
Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds. |
static void |
sleep(long millis,
int nanos)
Causes the currently executing thread to sleep (cease execution) for the specified number of milliseconds plus the specified number of nanoseconds. |
static void |
sleepUntil(long wakeUpTime)
Causes the currently executing thread to sleep (temporarily cease execution) until the specified moment in time. |
void |
terminate()
Interrupt and join. |
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, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface se.lth.cs.realtime.Activity |
isAlive, join, start |
Constructor Detail |
public JThread()
JThread
object with
a newly generated name in its father's ThreadGroup
.
Automatically generated names are of the
form "Thread-"+
n, where n is an integer.
public JThread(java.lang.String name)
JThread
object with
the specified name in its parent's ThreadGroup
.
name
- the name of the new thread.public JThread(java.lang.ThreadGroup group)
JThread
object with a newly generated name
in the specified ThreadGroup
.
Automatically generated names are of the
form "Thread-"+
n, where n is an integer.
group
- the ThreadGroup
of the new thread.public JThread(java.lang.ThreadGroup group, java.lang.String name)
JThread
object with
the specified name in the specified ThreadGroup
.
name
- the name of the new thread.group
- the ThreadGroup
of the new thread.Method Detail |
public RTEvent putEvent(RTEvent ev)
putEvent
in interface RTEventListener
ev
- Event to process or buffer for processing
public RTEventDispatcher getDispatcher()
RTEvent
s gets a
call of putEvent
which typically only stores/buffers the
event for later processing by the receiving thread (object). Thus,
the EventSource
simply dispatches the event distribution,
hence the name dispatcher of the lister list storage object.
getDispatcher
in interface RTEventSource
RTEvent
listeners. The returned dispatcher corresponds to the
javax.swing.event.EventListenerList
, but enhanced
for real-time usage.public void addListener(RTEventListener subscriber)
subscriber
as listener of application events
emitted from this thread object. An Activity
calling
OtherThread.addListener(this);
is the same as
OtherThread.getDispatcher().addListener( this, RTThread.currentThread().getPriority(), null);
addListener
in interface RTEventSource
subscriber
- the object interested in getting the events
via its putEvent
method.public static void sleepUntil(long wakeUpTime) throws RTInterrupted, RTDelayed
wakeUpTime
- the time to wake up.
java.lang.InterruptedException
- if another thread has interrupted
this thread.
RTDelayed
- if execution continues more than
maxTimeLag
too late.
RTInterrupted
public static void sleep(long millis) throws java.lang.InterruptedException
millis
- the length of time to sleep in milliseconds.
java.lang.IllegalArgumentException
- if the value of millis is
negative.
java.lang.InterruptedException
- if another thread has interrupted
this thread.Object.notify()
public static void sleep(long millis, int nanos) throws java.lang.InterruptedException
millis
- the length of time to sleep in milliseconds.nanos
- 0-999999 additional nanoseconds to sleep.
java.lang.IllegalArgumentException
- if the value of millis is
negative or the value of nanos is not in the range
0-999999.
java.lang.InterruptedException
- if another thread has interrupted
this thread.public void run()
run
method, first calling init
,
then calling perform
while not interrupted, and finally calling
exit. Hence, to define a repetitive thread, you can keep this run method and
instead override the perform
method. As well known, creation of
a new thread is accomplished by calling start
, which in turn
results in (in the context of the new thread) run
being called.
run
in interface java.lang.Runnable
public Timebase getTimebase()
getTimebase
in interface Activity
public Environment getEnv()
getEnv
in interface Activity
public void terminate()
terminate
in interface Activity
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |