为什么new MyCallable(100)不调用call方法还会出结果5050
ExecutorService pool=Executors.newFixedThreadPool(2);
Future<Integer> f1=pool.submit(new MyCallable(100));
Integer i =f1.get();
syso(i);
class MyCallable extends Callable{
private Integer i;
int sum=0;
public Callable(Integer i){
this.i=i;
}
public int call() throws exception{
for(int x=0;x<=i;x++){
sum+=i;
}
return sum;
}
3回答
-
慕粉1518463705
我都是一行一行分开的,怎么发了以后成一堆了,我也是醉了
-
慕设计4827416
这代码是全过程?,能规范打出出来