scala - reportFailure 方法在自定义 ExecutionContext 中实际做了什么
问题描述
我写了这段代码
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的目的是什么?当未来失败时,它不应该被调用吗?
解决方案
推荐阅读
- python - 我收到 NameError: name 'data' is not defined from selenium webscrape,但我已经在代码中定义了它,任何人都可以看到有什么问题吗?
- database - 使用 VBA 从前端访问表单重新链接后端 mdb
- php - laravel 检查用户是否创建了个人资料
- dart - 在 Flutter 中插入生成的列表
- amazon-web-services - 超过 AWS CloudFormation 速率
- typescript - 在不同类型的数组中查找
- bash - Golang OpenGL 错误 PlatformError: X11: The DISPLAY environment variable is missing panic: NotInitialized: The GLFW library is not initialized
- gradle - IntelliJ Gradle 意外删除自己的模块
- reactjs - React Native - (0, _redux.combineReducers) 不是函数
- visual-studio - 如何使用美元符号宏为 Winforms 项目设置工作目录?