作者AmosYang (LetMeGoogleThatForYou)
看板java
标题Re: [J2SE] 请问delay的方法
时间Sun Oct 4 23:44:33 2009
※ 引述《H45 (!H45)》之铭言:
: 标题: Re: [J2SE] 请问delay的方法
: 时间: Sun Oct 4 13:00:25 2009
:
: 自己包成 RuntimeException 之後呼叫这个方法就不用到处加 try catch。
:
: 推 PsMonkey:这招倒是没想过,我都乖乖包 try-catch XDXD 10/04 20:30
: → H45:当sleep太多的时候,这是让程式码稍微乾净一点的小技巧 :D 10/04 20:36
: → AmosYang:public static main(String[] x) throws Throwable // XD 10/04 23:27
碎碎念一下 :)
在写测试程式或 single-thread 程式时,这样写的确是简洁又方便,
但在写 multi-thread 程式时,可以参考这篇文章对 InterruptedException 的分析
( google://InterruptedException )
Java theory and practice: Dealing with InterruptedException
http://www.ibm.com/developerworks/java/library/j-jtp05236.html
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 65.87.177.87
1F:推 H45:两者可以并存,因为我还是有抛出例外,外面要不要catch都可以 10/05 09:43