If I setup an EC on top of a fixed-size threadpool like
val threadpool = Executors.newFixedThreadPool(10)
val ec: ExecutionContext = ExecutionContext.fromExecutor(threadpool)
and then schedule more than 10 (maybe way more) Futures on it,
val futs = (1 to 50).map { num => Future {
Thread.sleep(60000 * 60)
num
}(ec) }
futs.foreach(_.onComplete({
case Success(result) => logger.info(s"got: ${result}")
} )(ec))
is it possible to tell how many and which Futures are waiting to be executed at any given moment?
This is similar to scala - what is the best way to get the number of futures running in background in an execution context? - Stack Overflow, but it jstack -l
doesn’t have any EC/Future information.