Game of Life Simulation Using Multiple Threads

Write a multi-class multi-threaded Java program that simulates the game of life. Each cell will have its own thread dedicated to it to compute the cell's value in the next generation. This thread will be embedded in a class that is instantiated M*N times by the driver, once for each cell in the grid. Thread synchronization will be done with semaphores.

The primary problem you have to solve is coordinating all the cell threads during each generation. A cell thread cannot start computing the new cell value for the next generation until all other cells have completed their computation for the current generation. Use Java semaphores, that is P(S) and V(S) to solve this problem.

Have a look at a barrier. You will find it extremely useful! Here is an example program using a barrier.

For those needing help with creating a thread for each cell in the grid, have a look at this incorrect solution. Make sure you see why it is wrong.

Neither nap() nor sleep() is allowed.

If you have not already done so for game-of-life, animate your program using XtangoAnimator.