标签:超时
final ExecutorService exec = Executors.newFixedThreadPool(1); Callable<T> call = new Callable<T>() { @Override public T call() throws Exception { return t; } }; try { Future<T> future = exec.submit(call); T t = future.get(1000 * 5, TimeUnit.MILLISECONDS); // 任务处理超时时间设为 5 秒 } catch (TimeoutException ex) { } // 关闭线程池 exec.shutdown();
标签:超时
原文地址:http://blog.csdn.net/xcookies/article/details/43935827