just use "sleep" not "wait".
actually
Thread.sleep(4000); // sleeps for 4 secs
wait is a method in object to listen for "notify" calls from other part of the program (actually for another thread)
so, you put to wait an object if another event in other thread will "notify" in the future..
for an example https://www.tutorialspoint.com/java/lang/object_wait.htm
Actually, when using greenfoot, it is recommended to use the 'delay' method of the Greenfoot class. Messing with threads could conflict with how greenfoot deals with them (and using 'wait' is not recommended in the game development side of programming).
wait is a method in object to listen for "notify" calls from other part of the program (actually for another thread)
so, you put to wait an object if another event in other thread will "notify" in the future..
for an example https://www.tutorialspoint.com/java/lang/object_wait.htm
The 'wait' method can also be used for time, not only until notify() is called but it's a method in Object meant to be called on/from an Object, it doesn't stop the whole execution of a program.
See wait(long timeout, int nanos)
I still say (and I'm not the only one) to use Greenfoot.delay(
The 'wait' method can also be used for time, not only until notify() is called but it's a method in Object meant to be called on/from an Object, it doesn't stop the whole execution of a program.
It will not "stop the whole execution of the program"; but, it will delay the whole execution for the wait duration (meaning all actions are suspended until the wait is over).