Java_Thread類的sleep()與SystemClock類的sleep()的區別

我叫阿狸貓發表於2014-07-09
  • Thread.sleep()是java提供的函式。在呼叫該函式的過程中可能會發生InterruptedException異常。
  • SystemClock.sleep()是android提供的函式。在呼叫該函式的過程中不會發生InterruptedException異常,中斷事件將要被延遲直到下一個中斷事件。Use this function for delays if you do not use Thread.interrupt(), as it will preserve the interrupted state of the thread.

相關文章