Pauses the current thread for the specified number of seconds
使当前线程暂定 / 睡眠指定时长。
/**
* Pauses the current thread for the specified number of seconds.
*
* @param seconds The number of seconds to pause.
*/
void sleep(float seconds) {
long endTime = System.currentTimeMillis() + (long)(seconds*1000);
while (System.currentTimeMillis() < endTime) {
synchronized (this) {
try {
wait(endTime - System.currentTimeMillis());
} catch (Exception e) {
}
}
}
}