源码中是这样写的
public static ExecutorService setup(ExecutorService es) {
if (es != null)
return es;
if (es == null)
es = Executors.newFixedThreadPool(64);
Sender.es = es;
return es;
}
那么我如果这样初始化
int taskSize = 1000;
ExecutorService es = Executors.newFixedThreadPool(taskSize);
Sender.setup(es);
那么在执行的时候
Future<Response> response = Sender.create("http://baidu.com").setTimeout(7 * 1000).send(new Callback<Response>() {
@Override
public void invoke(Response res) {
System.out.println(Thread.currentThread().getName() + ":" + res.getStatus());
}
});
后台会报错
java.lang.IllegalStateException: Sender ExecutorService is null, Call setup first
也就是
Sender.setup(es);
如果传参,是没用的。。