How to configure a fine tuned thread pool for futures?
问题 How large is Scala's thread pool for futures? My Scala application makes many millions of future {} s and I wonder if there is anything I can do to optimize them by configuring a thread pool. Thank you. 回答1: You can specify your own ExecutionContext that your futures will run in, instead of importing the global implicit ExecutionContext. import java.util.concurrent.Executors import scala.concurrent._ implicit val ec = new ExecutionContext { val threadPool = Executors.newFixedThreadPool(1000)