OkHttp 2.0.0-RC1使用Dispatcher中ThreadPoolExecutor定义的:#getExecutorService
executorService = new ThreadPoolExecutor(
0, Integer.MAX_VALUE,
60, TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(),
Util.threadFactory("OkHttp Dispatcher", false));`
Run Code Online (Sandbox Code Playgroud)
这基本上是实现的Executors#newFixedThreadPool.
另一方面,Executors.newCachedThreadPool在平台#defaultHttpExecutor中定义的Retrofit使用归结为:
executorService = new ThreadPoolExecutor(
0, Integer.MAX_VALUE,
60, TimeUnit.SECONDS,
new SynchronousQueue<Runnable>(),
someThreadFactory);
Run Code Online (Sandbox Code Playgroud)
任何人都有任何想法为什么OkHttp使用Executors#newFixedThreadPool和改造Executors#newCachedThreadPool?