|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Process
A Process is a simulation of a thread of execution. A process repeats the behavior defined in its step() method until the completion of the step in which the time exceeds the simulation time. The simulation time can be set by invoking the static setSimulationTime() method. The simulation time and all other times are measured in milliseconds.
A process has a name formed by concatenating its class name with a String argument passed to the constructor. A process also has an average twiddle time specified by a constructor parameter. This time can be used to simulate any kind of time consuming operation.
All subclasses of Process should define constructors with at least two parameters: a name and an average twiddle time. They should be the first two parameters of a constructor. The first line of code in a constructor should invoke the superclass constructor, passing the first two parameters. Concrete subclasses must also implement the step() method. The twiddle() method can be invoked in step() to simulate time consuming processing.
Constructor Summary | |
Process(java.lang.String nm,
double t)
new Process(nm, t) returns a new process and starts executing its run method in a new thread. |
Method Summary | |
void |
run()
proc.run() runs the processing for proc, printing messages before and after processing. |
static void |
setSimulationTime(long t)
Process.setSimulationTime(t) sets the simulation time to t. |
protected abstract void |
step()
The step() method defines a step in the behavior of this process. |
java.lang.String |
toString()
proc.toString() returns the name of proc. |
void |
twiddle()
proc.twiddle() causes proc to do nothing significant for a random amount of time. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Process(java.lang.String nm, double t)
Method Detail |
public final void run()
run
in interface java.lang.Runnable
protected abstract void step()
public final void twiddle()
public java.lang.String toString()
toString
in class java.lang.Object
public static final void setSimulationTime(long t)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |