Sleep Function in Java
Published on May 5th, 2006 in Java
Ok, this post is for newbies. Some of you might have been looking for a similar function to Sleep() that you have come to know from Visual Basic. Well, it takes a bit more in Java, take a look at the following code. Simply insert it into your main function to try it out:
Share ThisLong stoptime = 2000L; //2 Seconds System.out.println("Going to sleep..."); try { Thread.sleep(stoptime); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("Woke up again!");
Trackback URL for this post:
http://www.yatblog.com/2006/05/05/sleep-function-in-java/trackback/
heads up December 2nd, 2007
heads up to anyone who copy pastes this and is still confused… it doesnt need to be in the main part of your program, and more importantly, change the capital L in Long to a lower case L –>”l”