My assignment is to add threading to a Java program that creates an "Orbital Fractal" through a GUI that allows the viewer to adjust colors, number of dots, etc. I've got the basic program all finished from a previous assignment, but I'm lost in regards to adding threading.

My basic confusion comes from the fact that almost every threading tutorial I've come across so far has the main class of the program using the threading. In the program we're doing, the main class runs everything, but only the drawing section of the application is supposed to be run in a thread.

The drawing right now is done in this function:
Code:
private void drawFractal(Graphics g, Dimension d)
    {
	double x = 0.0;
	double y = 0.0;
	int dmin = (d.width < d.height) ? d.width : d.height;
	
	double xmin = 0.0;
	double xmax = 0.0;
	double ymin = 0.0;
	double ymax = 0.0;
	
	for (int dot = 0; dot < nDots; ++dot) {
	    for (int dot2 = 0; dot2 < 1000; ++dot2) {
		double x2 = nextX(x, y);
		double y2 = nextY(x, y);
		xmin = (x2 < xmin) ? x2 : xmin;
		xmax = (x2 > xmax) ? x2 : xmax;
		ymin = (y2 < ymin) ? y2 : ymin;
		ymax = (y2 > ymax) ? y2 : ymax;
		x = x2;
		y = y2;
	    }
	    Thread.yield();
	}
	
	double dx = ((double) (d.width)) / (xmax - xmin);
	double dy = ((double) (d.height)) / (ymax - ymin);
	
	x = 0.0;
	y = 0.0;
	for (int dot = 0; dot < nDots; ++dot) {
	    g.setColor (interpolate(color1, color2, dot, nDots));
	    for (int dot2 = 0; dot2 < 1000; ++dot2) {
		double x2 = nextX(x, y);
		double y2 = nextY(x, y);
		int dotx = (int) (dx * (x2 - xmin));
		int doty = (int) (dy * (y2 - ymin));
		g.drawLine (dotx, doty, dotx, doty);
		x = x2;
		y = y2;
	    }
	    canvas.repaint();
	    Thread.yield();
	}
    }
In order to make this drawing be done in a thread should I be changing the main class of the application to be threaded and somehow include the above drawing code in a run function, or is there some way to convert the above function to be run as a thread?