[英]Signaling for exception from Callable thread without blocking in main thread
This is a followup for my previous question enter link description here 这是我上一个问题的跟进,请在此处输入链接描述
Now the problem is that I can't "block" (Future.get) in my main thread because it must continue with its work, but I do need the threads to signal it some how... 现在的问题是,我不能在主线程中“阻止”(Future.get),因为它必须继续工作,但是我确实需要线程向它发出一些信号……
Why not just call Future.isDone()
periodically from your main thread, and if done, Future.get()
the result ? 为什么不直接调用Future.isDone()
定期从你的主线程,如果做了, Future.get()
的结果? That will throw the original exception. 这将引发原始异常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.