java.lang.IllegalThreadStateException

K.I.L.E.R

Retarded moron
Veteran
http://members.optusnet.com.au/ksaho/Algorithm/JAVA/prototypes/test.zip

I keep getting that silly error.

I have successfully made a threaded app here:
http://members.optusnet.com.au/ksaho/Algorithm/JAVA/thread.java

I'm not doing anything different in my prototype game than in that threaded app.

I need to execute the thread in my game until the "enemy" is dead so hence I placed it into a while loop. I don't believe that it the problem though. If I take the "attDef.start();" command out of the loop and somewhere else it screws up. My program freezes.

Why is it playing with me? :(

DAMN thread. o_O

Thanks
 
It looks to me like you're attempting to start an already started thread; hence the illegal state exception. http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Thread.html#start()

A quick fix is to change line 207 [attDef.start()] to be something similar:
Code:
if (!attDef.isAlive()) {
    attDef.start();
}

However, I'd probably add a method to your 'pressButton' class:
Code:
private boolean started = false;

public boolean isStarted()
{
    return started;
}

public void run()
{
    started = true;
    // rest of original logic here ...
}

and change line 207 of test.java to be:
Code:
if (!attDef.isStarted()) {
    attDef.start();
}
 
Fixed it all. Logic error.

Taken majority of the crap out of btnContinue and knocked it into attack and defend. Works as intended.

Do I get a lolly? :)
 
Back
Top