首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Callable的三种应用方式

2012-12-23 
Callable的三种使用方式1。FutureTask ftnew FutureTask(new CallableObject(){@Override public Object

Callable的三种使用方式

1。

FutureTask ft=new FutureTask(new Callable<Object>(){@Override public Object call() throws Exception{// TODO Auto-generated method stubreturn null;}});ft.run();System.out.println(ft.get().toString());

?2。

ExecutorService es=Executors.newCachedThreadPool();Future f=es.submit(new Callable<Object>(){@Override public Object call() throws Exception{// TODO Auto-generated method stubreturn null;}});

?3。

Future f=es.submit(new FutureTask(new Callable<Object>(){@Override public Object call() throws Exception{// TODO Auto-generated method stubreturn null;}}));
?

热点排行