nachos.kernel.threads.test
Class ThreadTest

java.lang.Object
  extended by nachos.kernel.threads.test.ThreadTest
All Implemented Interfaces:
java.lang.Runnable

public class ThreadTest
extends java.lang.Object
implements java.lang.Runnable

Set up a ping-pong between two threads, by forking two threads to execute SimpleRunnable objects.


Field Summary
private static java.util.Collection argsC
          Collection containing the command-line arguments.
private static ThreadTest t1
          Static variables to hold the instances we create and keep them from being garbage collected.
private static ThreadTest t2
          Static variables to hold the instances we create and keep them from being garbage collected.
private  int which
          Integer identifier that indicates which thread we are.
 
Constructor Summary
ThreadTest(int w)
          Initialize an instance of ThreadTest and start a new thread running on it.
 
Method Summary
 void run()
          Loop 5 times, yielding the CPU to another ready thread each iteration.
static void start(java.lang.String[] args)
          Entry point for the test.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

t1

private static ThreadTest t1
Static variables to hold the instances we create and keep them from being garbage collected.


t2

private static ThreadTest t2
Static variables to hold the instances we create and keep them from being garbage collected.


which

private int which
Integer identifier that indicates which thread we are.


argsC

private static java.util.Collection argsC
Collection containing the command-line arguments. Putting them in a collection makes it easier to test whether a given argument is present.

Constructor Detail

ThreadTest

public ThreadTest(int w)
Initialize an instance of ThreadTest and start a new thread running on it.

Parameters:
w - An integer identifying this instance of ThreadTest.
Method Detail

start

public static void start(java.lang.String[] args)
Entry point for the test.

Parameters:
args - Array containing command-line arguments.

run

public void run()
Loop 5 times, yielding the CPU to another ready thread each iteration.

Specified by:
run in interface java.lang.Runnable