Homework #3

Assigned: February 20
Due: February 27, 3:00pm


(32 points) In problem #2 of HW #1, you were asked to spawn and sychronize 20 processes, each with a single thread of control, to produce the desired output. In this problem, you are asked to write a Java program /home/<logname>/homeworks/hw3/operating.java as one process with 20 threads of control, and spawn and sychronize those threads to print the following to standard error (of course, with different thread ids):

Thread 10: operating
Thread 11: systems
Thread 12: operating
Thread 13: systems
Thread 14: operating
Thread 15: systems
Thread 16: operating
Thread 17: systems
Thread 18: operating
Thread 19: systems
Thread 20: operating
Thread 21: systems
Thread 22: operating
Thread 23: systems
Thread 24: operating
Thread 25: systems
Thread 25: operating
Thread 26: systems
Thread 27: operating
Thread 28: systems
Each line must be printed to standard error by a different thread, and you must not use any Java synchronization mechanisms not presented in class. In other words, do not use any Java constructs not presented in class. Do not use sleep, wait, await, yield, or any other similar method. Also, the threads need not print in the order in which they were created, but they must alternate between printing operating and systems.

Keep your program to approximately 30 lines of code.


Return Home