|
The following text has been provided by
Leah DeBruycker as a part of her Computer Science 310 Operating Systems Class Project
Our assignment was to write a program in Java that would have four threads, each represented by a different color, take a random "walk" around a 10x10 grid. The first thread to get to all 100 squares would be the winner. The winner would then wait for all other threads to finish their "walk" and then it would take a victory lap, painting all of the squares its color.
Here are what the colors mean:
Red, blue, green, and yellow are the colors of the Walker threads. When a thread is the first one to visit a square it paints its color on that square. When a thread is the second or third visitor to a square, the square is painted orange. After all four Walkers have been to a square it is colored magenta/pink. After all squares are magenta (meaning all four threads have been to all squares), the winning threads begins painting all of the squares its color.
Every time you run it you will see different results! Check it out!
Run the program: See Who Wins this time!
(Viewing this project requires Java to be installed on your computer.)
|