Difference between SystemClock.sleep and Thread.sleep

  • Thread.sleep() is a function provided by java. An InterruptedException may occur during a call to this function.
  • SystemClock.sleep() is a function provided by android. In the process of calling this function, InterruptedException will not occur, and the interrupt event will be delayed until the next interrupt event. Use this function for delays if you do not use Thread.interrupt(), as it will preserve the interrupted state of the thread.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325989990&siteId=291194637