Thread Exception - StackOverFlow
This code creates a "missile" by mouse clicks:
publicboolean mouseDown(Event e,int x,int y)
{
missiles[mc].reset(x,y);
enemyMissiles[emc].reset();
if (mc < missiles.length-1)
mc++;
else
mc = 0;
if (emc < enemyMissiles.length-1)
emc++;
else
emc = 0;
repaint();
returntrue;
}
Missile Class:
This is where I think the problem must be because after a certain amount of clicks the threads stop and I get a stack overflow, the run() method is screwy i guess:
package mainPackage;
publicclass Missileextends Threadimplements Runnable{
privateint destX, destY, size, alpha;
public Missile()
{
start();
}
publicvoid reset(int x,int y)
{
destX = x;
destY = y;
size=1;
alpha = 255;
}
publicint getDestX()
{
return destX;
}
publicint getDestY()
{
return destY;
}
// used for centering ovals
publicint getCenterX()
{
return destX-size/2;
}
// used for centering ovals
publicint getCenterY()
{
return destY-size/2;
}
publicint getSize()
{
return size;
}
publicint getAlpha()
{
return alpha;
}
publicvoid run()
{
if (size < 150)
size++;
if (alpha > 0)
alpha--;
try{sleep(5);}
catch (Exception e)
{e.printStackTrace();}
run();
}
}
If someone can please spot any errors, I would greatly appreciate it.

