我环顾四周,有很多例子,但找不到直接的答案。请参见下面的代码。我不想将我的可调用任务提交给执行者以取得未来。我只是想称其为原始。所以我直接调用.call()会阻塞当前线程吗?我的意思是会阻止通话吗?谢谢
public class CustomCallable implements Callable<Long> {
private long number;
public CustomCallable(final long number) {
this.number = number;
}
@Override
public Long call() throws Exception {
//do something
return number;
}
}
public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
Callable<Long> cCallable = new CustomCallable(i);
cCallable.call();//The question is: is this going to block until it finishes the current call,or continue spinning others. Is the loop going to continue without waiting the previous call? or just continue until it reaches <10?
}
}