Sunday, 15 May 2011

java - Delay a for loop for a certain number of seconds -


I have this kind of loop:

 for  (int i = 0; i & lt; 10; i ++) {// do something / delay for 5 seconds, then go to the next recurrence of the loop}  

How do I specify delay in Java?

The default way to do this is Thread.sleep (5000). Generally it is used in context. For

  (int i = 0; i <10; i ++) {// do something / delay for 5 seconds, go to the next launch recital {Thread. Sleep (5000)); } Grip (Interrupted E) E. {// TODO Auto-Generated Catch Block e.printStackTrace (); }}  

No comments:

Post a Comment