首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 系统运维 >

线程池跟SystemClock

2012-06-27 
线程池和SystemClockprivate ExecutorService executorService Executors.newFixedThreadPool(5) // 固

线程池和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();        }    }
?

?

?

热点排行