线程池和SystemClock
private ExecutorService executorService = Executors.newFixedThreadPool(5); // 固定五个线程来执行任务
?
SystemClock.sleep(2000);这个方法只是封装了Thread.sleep,不会抛出中断异常
?
SystemClock:public static void sleep(long ms) { long start = uptimeMillis(); long duration = ms; boolean interrupted = false; do { try { Thread.sleep(duration); } catch (InterruptedException e) { interrupted = true; } duration = start + ms - uptimeMillis(); } while (duration > 0); if (interrupted) { // Important: we don't want to quietly eat an interrupt() event, // so we make sure to re-interrupt the thread so that the next // call to Thread.sleep() or Object.wait() will be interrupted. Thread.currentThread().interrupt(); } }?
?
?