Thread.sleep()是java提供的函数。在调用该函数的过程中可能会发生InterruptedException异常。
SystemClock.sleep()是android提供的函数。在调用该函数的过程中不会发生InterruptedException异常,中断事件将要被延迟直到下一个中断事件。
SystemClock.sleep(millis) is a utility function very similar to Thread.sleep(millis), but it ignores InterruptedException. Use this function for delays if you do not use Thread.interrupt(), as it will preserve the interrupted state of the thread.
本文介绍了Java中Thread.sleep()与Android中SystemClock.sleep()的区别。前者在使用过程中可能会抛出InterruptedException异常;而后者则不会抛出此异常,而是会延迟中断事件,适用于不使用Thread.interrupt()的情况。
5174

被折叠的 条评论
为什么被折叠?



