ExecutorService es = Executors.newCachedThreadPool();
Future<?> future = es.submit(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
try{
Thread.sleep(300000l);
System.out.println("begin");
for(int i=0;i<100000;i++){
if(Thread.currentThread().isInterrupted()){
System.err.println("Interrupted");
break;
}
System.out.println(i);
}
System.out.println("finish");
}catch (InterruptedException e) {
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}
}
});
Thread.sleep(1*1000l);
future.cancel(true);
System.out.println("interupt is send");
分享到:
相关推荐
英语:unit3 life in the future单元同步测试.docx
Unit 5 My Future单元测试(冀教版八上)2.doc
Unit 5 My Future Lesson 41测试题(冀教版九上)2.doc
Future
牛津深圳版八年级下册Unit-8-Life-in-the-future单元综合测试题2.doc
使用future处理并发1
【最新】外研版七年级英语下册Module-4--Life-in-the-future-模块测试题(附答案).doc
Unit 5 My Future综合测试(冀教版九上)2.doc
高一英语必修5 Unit 3 Life in the future单元测试题精选.doc
高一英语必修5 Unit 3 Life in the future 单元测试 试卷精选.doc
新人教版Unit 6 Life in the future单元测试题[精选].doc
Future模式可以这样来描述:我有一个任务,提交给了Future,Future替我完成这个任务。期间我自己可以去做任何想做的事情。一段时 间之后,我就便可以从Future那儿取出结果。就相当于下了一张订货单,一段时间后可以...
Crafting Your Research Future
这个资源文件中,包含了停止线程和取消线程任务的案例代码,介绍了四五种停止线程、取消线程任务的方式,有Thread.stop()、Thread.interrupt()、future,cancel(true)等等,也可以查看文章...获取。
python安装打包依赖包-future-0.18.1.tar.gz
Future示例
ProfipipsHunter Future
2015年春高中英语 Unit3 Life in the future综合测试题 新人教版必修5
python库。 资源全名:future-0.12.0.tar.gz
future-0.18.3