public class MandelbrotHandler { final MandelbrotThread[] threads; final Object waitForCommand = new Object(); final Object waitForRender = new Object(); final Object lock = new Object(); int renderingThreads = 0; MandelbrotImage mi = null; public MandelbrotHandler(int numThreads) { threads = new MandelbrotThread[numThreads]; for (int i = 0; i < numThreads; i++) { threads[i] = new MandelbrotThread(0, 0, null, this); threads[i].setDaemon(true); threads[i].start(); } } public void setImage(MandelbrotImage mi) { this.mi = mi; int rowCount = mi.getHeight() / threads.length; int rowStart = 0; for (int i = 0; i < threads.length; i++) { threads[i].mi = mi; threads[i].rowMin = rowStart; threads[i].rowMax = (rowStart += rowCount); } renderingThreads = threads.length; } public void waitForRenderCommand() { // TODO: add code to wait for a render command here // You should use the waitForCommand object to wait on. } public void waitForRenderToFinish() { // TODO: add code to wait for a render to finish here // You should use the waitForRender object to wait on. } public void sendRenderCommand() { // TODO: add code to send a render command here // You should use the waitForCommand object send the notification. } public void sendRenderFinished() { // TODO: add code to send a render finished notification here // You should use the waitForRender object send the notification. } }