先看代码:
blic static void main(String[] args) {
ArrayList<Future<String>> list = new ArrayList<Future<String>>(); ExecutorService es = Executors.newCachedThreadPool();
for (int i = 0; i < 5; i++) {
list.add(es.submit(new ThreadCall(i)));
}
es.shutdown();
for (Future<String> fs : list) {
try {
System.out.print(fs.get());
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
红色的字..<>号里的信息看不懂.以前没见过..如果直接用ArrayList list = new ArrayList();那么紫色的字就披错..
麻烦哪位详细讲解下... 

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【GatoAngel】截止到2008-07-03 22:57:21的历史汇总数据(不包括此帖):
    发帖的总数量:2                        发帖的总分数:40                       
    结贴的总数量:2                        结贴的总分数:40                       
    无满意结贴数:0                        无满意结贴分:0                        
    未结的帖子数:0                        未结的总分数:0                        
    结贴的百分比:100.00%               结分的百分比:100.00%                  
    无满意结贴率:0.00  %               无满意结分率:0.00  %                  
    敬礼!
      

  2.   

    顺便问下紫色的字Future <String> fs : list  是什么意思...循环多少次/
      

  3.   

    <>内部的是java5以后的新特性: 泛型 ,楼主可以搜索相关资料看下!
      

  4.   

    ArrayList <Future <String>> list = new ArrayList <Future <String>>();
    是泛型 的写法,强制了ArrayList里放的东西只能是Future类型的,Future <String>同理,
    Future <String> fs : list 遍历fs里的东西。循环多少次要看你的fs的SIZE了,