tag:blogger.com,1999:blog-32362353.post115773021971911180..comments2023-10-07T09:30:24.139-07:00Comments on Mark's Tech Stuff: Java. Pause MethodAnonymoushttp://www.blogger.com/profile/04556772785759586264noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-32362353.post-89906558806412437272011-10-28T07:21:04.011-07:002011-10-28T07:21:04.011-07:00This comment has been removed by a blog administrator.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-32362353.post-87703386479625367682011-10-28T06:47:46.411-07:002011-10-28T06:47:46.411-07:00TROLOLOLTROLOLOLAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-32362353.post-31886311261611950162009-11-25T06:00:15.450-08:002009-11-25T06:00:15.450-08:00Threading is not so good either, there are better ...Threading is not so good either, there are better ways to do that by creating a timer and then a action listener.Unknownhttps://www.blogger.com/profile/09660912749745440357noreply@blogger.comtag:blogger.com,1999:blog-32362353.post-46117824800442260172008-05-26T13:44:00.000-07:002008-05-26T13:44:00.000-07:00Mike, this is how you would do it.public class Wai...<B>Mike, this is how you would do it.</B><BR/><BR/>public class Wait {<BR/> public static void oneSec() {<BR/> try {<BR/> Thread.currentThread().sleep(1000);<BR/> }<BR/> catch (InterruptedException e) {<BR/> e.printStackTrace();<BR/> }<BR/> } <BR/> public static void manySec(long s) {<BR/> try {<BR/> Thread.currentThread().sleep(s * 1000);<BR/> }<BR/> catch (InterruptedException e) {<BR/> e.printStackTrace();<BR/> }<BR/> }<BR/>}<BR/><BR/><B>This is how to test it.</B><BR/><BR/>public class TestWait {<BR/> public static void main(String args[]) {<BR/> System.out.println("Wait one second");<BR/> Wait.oneSec();<BR/> System.out.println("Done\nWait five seconds");<BR/> Wait.manySec(5);<BR/> System.out.println("Done");<BR/> }<BR/>}Adamhttps://www.blogger.com/profile/01543542333079779227noreply@blogger.comtag:blogger.com,1999:blog-32362353.post-70800163404905230802008-03-09T08:07:00.000-07:002008-03-09T08:07:00.000-07:00"Thread.sleep(1000); (for one second)and catch the..."Thread.sleep(1000); (for one second)<BR/>and catch the InterruptedException"<BR/><BR/>I'm a little new to progamming - could you post an example of this and maybe explain it a little. For example, what does "catch" and "InterruptedException" mean and should they be a part of the program - if so - how?Mikehttps://www.blogger.com/profile/12825302693667427720noreply@blogger.comtag:blogger.com,1999:blog-32362353.post-23404240624547294852008-01-09T12:53:00.000-08:002008-01-09T12:53:00.000-08:00caboom: Thanks! You just saved me hours of hair pu...caboom: Thanks! You just saved me hours of hair pulling!Unknownhttps://www.blogger.com/profile/08494224209601786577noreply@blogger.comtag:blogger.com,1999:blog-32362353.post-1167569407665123722006-12-31T04:50:00.000-08:002006-12-31T04:50:00.000-08:00good idea. thanks for that.Link to Thread.sleepgood idea. thanks for that.<BR/><BR/><A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#sleep(long)" REL="nofollow">Link to Thread.sleep</A>Anonymoushttps://www.blogger.com/profile/04556772785759586264noreply@blogger.comtag:blogger.com,1999:blog-32362353.post-1167245481720170382006-12-27T10:51:00.000-08:002006-12-27T10:51:00.000-08:00this method sucksit uses loops and consumes all of...this method sucks<BR/>it uses loops and consumes all of the cpu for as long the loop lasts.<BR/><BR/>use:<BR/><BR/>Thread.sleep(1000); (for one second)<BR/>and catch the InterruptedExceptioncaboomhttps://www.blogger.com/profile/06944831881417835554noreply@blogger.com