Class Process

java.lang.Object
  |
  +--Process
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
BoundedBufferProcess, Philosopher, SharedDataProcess

public abstract class Process
extends java.lang.Object
implements java.lang.Runnable

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

Process

public 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. The name of the new process is formed by concatenating its class name with nm. The average twiddle time of the new process is t.
Method Detail

run

public final void run()
proc.run() runs the processing for proc, printing messages before and after processing.
Specified by:
run in interface java.lang.Runnable

step

protected abstract void step()
The step() method defines a step in the behavior of this process.

twiddle

public final void twiddle()
proc.twiddle() causes proc to do nothing significant for a random amount of time. The average twiddle time for proc is specified when it is constructed.

toString

public java.lang.String toString()
proc.toString() returns the name of proc.
Overrides:
toString in class java.lang.Object

setSimulationTime

public static final void setSimulationTime(long t)
Process.setSimulationTime(t) sets the simulation time to t. All processes will terminate after completing a step in which the total elapsed time exceeds the simulation time.