|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.newisys.eventsim.SimulationThread
public final class SimulationThread
Represents a thread of execution in a simulation.
Note: This class does not extend java.lang.Thread to avoid exposing Thread methods that should not be used with simulation threads.
| Method Summary | |
|---|---|
static SimulationThread |
currentThread()
Returns the current simulation thread. |
static SimulationThread |
currentThreadOrNull()
Returns the current simulation thread, or null if the current thread is not a simulation thread. |
static SimulationThread |
forThread(Thread javaThread)
Returns the simulation thread object corresponding to the given Java thread. |
static SimulationThread |
forThreadOrNull(Thread javaThread)
Returns the simulation thread object corresponding to the given Java thread, or null if the given thread is not a simulation thread. |
List<SimulationThread> |
getChildren()
Returns a list of child threads (i.e. |
Event |
getJoinEvent()
Returns the event that will be notified when this thread terminates. |
SimulationManager |
getManager()
Returns the SimulationManager that manages this thread. |
String |
getName()
Returns the name of this thread. |
SimulationThread |
getParent()
Returns the parent thread of this simulation thread, or null if this is a top-level thread (created by a non-simulation thread). |
PRNG |
getRandom()
Returns the random number generator for this thread. |
PRNGFactory |
getRandomFactory()
Returns the factory used to create random number generators for child threads. |
ThreadState |
getState()
Returns the current state of this thread. |
void |
join()
Waits until this thread terminates. |
void |
join(SimulationThread thread)
Waits until the given thread has terminated. |
void |
joinAll(Collection<SimulationThread> threads)
Waits until all of the threads in the given collection have terminated. |
void |
joinAll(SimulationThread... threads)
Waits until all of the given threads have terminated. |
void |
joinAny(Collection<SimulationThread> threads)
Waits until any of the threads in the given collection have terminated. |
void |
joinAny(SimulationThread... threads)
Waits until any of the given threads have terminated. |
void |
joinChildren()
Waits until all of the current child threads of this thread (and their descendents) have terminated. |
void |
setRandom(PRNG random)
Sets the random number generator for this thread. |
void |
setRandomFactory(PRNGFactory randomFactory)
Sets the factory used to create random number generators for child threads. |
void |
terminate()
Terminates this thread, either immediately if it currently PENDING or BLOCKED, or at its next synchronization point if it is RUNNING, and waits for the thread to become TERMINATED. |
void |
terminateChildren()
Terminates all of the child threads of this thread (and their descendents) by calling the terminate() method on them. |
String |
toString()
|
void |
waitFor(Event e)
Waits until the given event occurs. |
void |
waitForAll(Collection<? extends Event> events)
Waits until all of the events in the given collection have occurred. |
void |
waitForAll(Event... events)
Waits until all of the given events have occurred. |
void |
waitForAny(Collection<? extends Event> events)
Waits until any of the events in the given collection have occurred. |
void |
waitForAny(Event... events)
Waits until any of the given events have occurred. |
void |
yield()
Suspends this simulation thread until all other currently runnable threads have had a chance to run. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public static SimulationThread currentThread()
IllegalThreadExceptionpublic static SimulationThread currentThreadOrNull()
public static SimulationThread forThread(Thread javaThread)
javaThread - a Java thread
IllegalThreadExceptionpublic static SimulationThread forThreadOrNull(Thread javaThread)
javaThread - a Java thread
public String getName()
public SimulationManager getManager()
public SimulationThread getParent()
public List<SimulationThread> getChildren()
public ThreadState getState()
public Event getJoinEvent()
public PRNG getRandom()
public void setRandom(PRNG random)
random - a new PRNG instance for this threadpublic PRNGFactory getRandomFactory()
public void setRandomFactory(PRNGFactory randomFactory)
randomFactory - a new PRNGFactory instance for this threadpublic void yield()
This method must be called from the Java thread associated with this simulation thread.
public void waitFor(Event e)
This method must be called from the Java thread associated with this simulation thread.
e - the event to wait forpublic void waitForAny(Event... events)
This method must be called from the Java thread associated with this simulation thread.
events - an array of events to wait onpublic void waitForAny(Collection<? extends Event> events)
This method must be called from the Java thread associated with this simulation thread.
events - a collection of events to wait onpublic void waitForAll(Event... events)
This method must be called from the Java thread associated with this simulation thread.
events - an array of events to wait onpublic void waitForAll(Collection<? extends Event> events)
This method must be called from the Java thread associated with this simulation thread.
events - a collection of events to wait onpublic void join()
This method must be called from a Java thread other than the one associated with this simulation thread.
public void joinChildren()
public void join(SimulationThread thread)
This method must be called from the Java thread associated with this simulation thread.
thread - the thread to wait onpublic void joinAny(SimulationThread... threads)
This method must be called from the Java thread associated with this simulation thread.
threads - an array of threads to joinpublic void joinAny(Collection<SimulationThread> threads)
This method must be called from the Java thread associated with this simulation thread.
threads - a collection of threads to joinpublic void joinAll(SimulationThread... threads)
This method must be called from the Java thread associated with this simulation thread.
threads - an array of threads to joinpublic void joinAll(Collection<SimulationThread> threads)
This method must be called from the Java thread associated with this simulation thread.
threads - a collection of threads to joinpublic void terminate()
This method may be called from any thread.
public void terminateChildren()
For each thread, it first takes a snapshot of the current list of children, before recursively terminating them. This implies that if a thread creates new threads before it terminates, those threads will not be terminated.
This method may be called from any thread.
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||