Re: [J2SE] 請問delay的方法
看板java作者AmosYang (LetMeGoogleThatForYou)時間16年前 (2009/10/04 23:44)推噓1(1推 0噓 0→)留言1則, 1人參與討論串7/12 (看更多)
※ 引述《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
推
10/05 09:43, , 1F
10/05 09:43, 1F
討論串 (同標題文章)