import java.util.LinkedList; import java.util.List; public class GameOfLife { public GameOfLife(Environment env) { this.env = env; } Environment env; List threads = new LinkedList(); public void start() { setThreadCount(1); } synchronized void setThreadCount(int numberOfThreads) { for (GOLThread golThread : threads) { golThread.exiting(); } for (GOLThread golThread : threads) { try { golThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } } for (int i = 0; i < numberOfThreads; ++i) { GOLThread golThread = new GOLThread(this); threads.add(golThread); golThread.start(); } } }