In this project you will write a multithreaded program to render fractals on the screen. If you are running your program on hardware that supports multithreading, then this results in a program that renders faster than a single-threaded version.
You are to write a Java program (applet or application) that renders the Mandelbrot set. All of the requirements below need to be met.
ComplexNumberclass with methods for add, multiply, and norm (i.e. absolute value - the distance to the origin).
mkeys to multiply or divide the max number of iterations by 2). This is useful when zooming in on the fractal.
One possible design would be to implement the following classes:
Taskwould describe the task of computing the fractal on some rectangular subset of the pixel region.
TaskQueueis a class that gets constructed with an array of
Taskobjects, and gives
Tasksto callers that ask for one. This doesn't even need to be a true queue, since all of the objects it will ever contain are known when it is created.
Workerobject starts a thread on itself and keeps completing tasks until there are none left in the queue. It may need to have a reference to the applet so that it can notify it to repaint the screen. Also, the workers might share pointers to an array that indicates how many iterations it took for each pixel (to be used by the applet in painting).
FractalAppletclass that manages zoom levels, sets up the other helper objects whenever the view of the fractal changes, and does the actual painting.
The project is due at the beginning of class on Friday, September 10, 2010. Be sure to give your entire program a good proofread before handing it in; even small errors will result in me handing it back for another iteration.