(something).wait() keeps giving me an error...
Hi, I am a first-time game programmer, so I am kind of new at Java...
Basically, I want the player's ship to fire an "absorber" whenever he or she presses the predefined-key.
The absorber will go out, then execute 3 explosions 1.5 seconds apart. I have a method explode(), and a method travel(). I have no trouble calling the travel() method, but how do I get the explode method to execute 3 times, 1.5 seconds apart? I tried:
privatevoid travel()
{
...
explode();
try{
this.wait(1500)// and creating a blank object, then calling object.wait(1500) // haven't had any other ideas
}catch(InterruptedException ie)
{}
}
But whenever the program gets to the line after the try line it creates an "IllegalMonitorStateException: current thread not owner". What does that mean? Obviously I am not telling the right thing to wait(). What do I do?
Thanks in advance.
[1265 byte] By [
aRyan316a] at [2007-10-1 20:51:03]

Oopsies. Just looking over what I typed, and it's supposed to be...
private void travel()
{
...
explode();
try{
this.wait(1500)// and creating a blank object, then calling object.wait(1500) // haven't had any other ideas
} catch(InterruptedException ie)
{ }
explode();
try{
... .wait(1500;
}catch(... ie)
{}
explode();
}
Sorry about that. typing in a hurry for some reason, didn't read over what I typed =\
Ok, well, I added those synchronized(this) things to the code, and the program does correctly wait 1.5 seconds between explosions, but my screen doesn't refresh, and I feel that I put enough yields all over the place. Well, do I have to make the thread "sleep" or what? Sorry, in case you haven't noticed, I'm pretty new at this... and "sleeping" "waiting" and "yielding" is not in the textbook that I got from camp...
private void travel(){
...
System.out.println("Explosion 1");
explode();
try{synchronized(this){
Thread.yield();
wait(1500);
Thread.yield();
}
}catch(InterruptedException ie){
ie.printStackTrace();
}
explode();
System.out.println("Explosion 2");
try{synchronized(this){
Thread.yield();
wait(1500);
Thread.yield();
}
}catch(InterruptedException ie){
ie.printStackTrace();
}
explode();
System.out.println("Explosion 3");
}
Anyway, I get an Explosion 1 in my console, and then the game temporarily freezes, then Explosion 2, and then after Explosion 3 the game "unfreezes." Obviously this thread is hogging up the program. What do I do? Once again, thanks in advance.