reportFailure方法在自定义ExecutionContext

时间:2018-05-07 16:04:36

标签: scala

我写了这段代码

val myEc = new ExecutionContext {
    val tp = Executors.newFixedThreadPool(2)
    def execute(r: Runnable) { tp.submit(r) }
    def reportFailure(t: Throwable) { println("ho ha ha ... something broke!") }
}

val f : Future[Int] = Future(throw new Exception("123"))(myEc)
Await.result(f, Duration.Inf)

该程序不打印“ho ha ha”...那么reportFailure的目的是什么呢?当未来失败时,它不应该被召唤吗?

0 个答案:

没有答案