CS345 Operating Systems
Spring 2004
Laboratory Assignment 3
The purpose of this
assignment is to give you the opportunity to write a Java program that
uses threads. You should also better understand the
concurrent execution nature of operating systems.
You are to write a Java program using
threads that does the following:
- Has a Clock thread that updates
(adds 1) to a counter every second
- Has a main which does the following:
- Starts the Clock thread
- Enters a loop that does the
following
- Asks the user to enter a command
- Reads the command
- If the command is the letter "P"
prints out the value of the clock counter
- If the command is the letter "R"
resets the clock to 0
- If the command is the letter "X"
terminates the program (see if you can figure out how to terminate the
thread as well as main)
You should verify that the clock
counter accurately reflects the time between two "P" commands.