2
如何在Dispatch中替換默認線程池?我在這裏看到https://github.com/dispatch/dispatch/blob/master/futures/src/main/scala/Futures.scala實例化CachedThreadPool。我想用FixedThreadPool來代替。如何在Dispatch中替換默認線程池?
如何在Dispatch中替換默認線程池?我在這裏看到https://github.com/dispatch/dispatch/blob/master/futures/src/main/scala/Futures.scala實例化CachedThreadPool。我想用FixedThreadPool來代替。如何在Dispatch中替換默認線程池?
恩,對不起,因爲懶惰,夥計們。快速查看Dispatch的來源顯示,我可以通過setExecutorService
的Http.configure
傳遞我的線程執行程序。
例如
val pool: ExecutorService = Executors.newFixedThreadPool(4)
val httpClient: Http = Http.configure(_.setAllowPoolingConnection(true).setFollowRedirects(true).setConnectionTimeoutInMs(1000).setExecutorService(pool))
唯一的問題是,它沒有工作。調度不使用我通過的對象:(我稍後會發布更新。 – expert