Does anyone here know anything about
I need to know how to do a delay in java?
e.g. I need the program to do something, wait 2 seconds, then do something else. Anyone able to help out?
( ,
Wed 26 Jan 2005, 23:47,
archived)
I need to know how to do a delay in java?
e.g. I need the program to do something, wait 2 seconds, then do something else. Anyone able to help out?
i haven't programmed java in over a year
but i believe
an easy way to do it would to just make a module with a for loop that does nothing several thousand times and you can call that whenever you need. trial and error, for delay length, i believe. but there has to be a more elegant way to do it.
[edit: you can access the system clock, right? maybe you could do a while loop that stores the first value on the system clock and continues until that has progressed by two seconds. or maybe i'm making stuff up.]
( ,
Wed 26 Jan 2005, 23:49,
archived)
an easy way to do it would to just make a module with a for loop that does nothing several thousand times and you can call that whenever you need. trial and error, for delay length, i believe. but there has to be a more elegant way to do it.
[edit: you can access the system clock, right? maybe you could do a while loop that stores the first value on the system clock and continues until that has progressed by two seconds. or maybe i'm making stuff up.]
java
try Thread.sleep(2000);
java.sun.com/j2se/1.4.2/docs/api/java/lang/Thread.html#sleep(long)
( ,
Wed 26 Jan 2005, 23:55,
archived)
java.sun.com/j2se/1.4.2/docs/api/java/lang/Thread.html#sleep(long)