This site requires JavaScript, please enable it in your browser!
Greenfoot back
Kalpshah6
Kalpshah6 wrote ...

2017/5/17

Not able to understand wait methd

Kalpshah6 Kalpshah6

2017/5/17

#
I am not able to use the wait method. I just want to stop the game for a minute.
Yehuda Yehuda

2017/5/18

#
jaimev jaimev

2017/5/18

#
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
danpost danpost

2017/5/18

#
jaimev wrote...
just use "sleep" not "wait".
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).
Yehuda Yehuda

2017/5/19

#
jaimev wrote...
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(
danpost danpost

2017/5/19

#
Yehuda wrote...
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).
You need to login to post a reply.