当前位置: 代码迷 >> 综合 >> SystemClock.sleep()和Thread.sleep()区别
  详细解决方案

SystemClock.sleep()和Thread.sleep()区别

热度:32   发布时间:2023-10-09 00:16:05.0

Thread.sleep()是java提供的函数。在调用该函数的过程中可能会发生InterruptedException(中断异常)。

SystemClock.sleep()是android提供的函数。在调用该函数的过程中不会发生InterruptedException异常,中断事件将要被延迟直到下一个中断事件。

两者都可以用,在android中最好使用后者.

  相关解决方案