- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
上下文:我对 Spring 非常陌生,以前从未使用过 @Async。我被指示根据电子邮件中发送给我的示例代码复制部分代码。
如果我要这样做,根据 @async 的文档和指南,我能知道的唯一方法是使用 Future.isDone() 并且可能有一个列表,我可以在节点“完成”时从中删除节点“并在列表为空后继续。
我想知道是否还有其他方法可以知道“ future ”何时完成?
在给我的示例代码中没有 future.isDone() 行。
他们只是在发出异步请求后调用另一个函数,该函数使用 for 循环作为
for (Entry<AClass, Future<String>> a : b.entrySet()) {
这里是否有某种神奇的迭代器巫术与“foreach”一起发生,或者我的示例代码是否有人给我不完整,或者这里还有其他事情发生?
最佳答案
我相信您对 future.isDone()
方法感到困惑
isDone 它只会返回 true 或 false
Returns true if completed in any fashion: normally, exceptionally, or via cancellation.
要对 Future 对象执行操作,您不需要调用 future.isDone()
并确定任务是否完成
公共(public) T get() 抛出InterruptedException, ExecutionException(您应该看到这个方法)
Waits if necessary for this future to complete, and then returns its result.
Throws:
CancellationException - if this future was cancelled
ExecutionException - if this future completed exceptionally
InterruptedException - if the current thread was interrupted while waiting
关于java - @Async, future ,AsyncResult; "awaiting"完成异步函数有哪些方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53964039/
我是 JBoss 世界的新手,目前正在开发我的第一个程序。因此,如果我的问题很琐碎,请提前原谅。但是我仍然不知道答案(已经在 JBoss 社区和 Coderanch 中询问过),所以如果有人能给我
我有一个 celery 设置,它使用两个不同的服务器来处理任务。我试图找出匹配任务完成的服务器的最佳方法。我查看了文档,没有看到任何关于从 AsyncResult 检索主机名的信息。 对此事的任何意见
我有几个异步方法 (Annotatad @Asynchronous) 返回 future 对象。我必须立即执行它们,但这足以让我获得第一个准备就绪的结果,是否有任何适用于 Java EE 容器的安全可
我有一个简单的代码,如下所示。第一个进程阻止了队列,因此它们都没有完成。 如果 AsyncResult 超过 .get() 超时,我希望能够终止它,这样我的池队列就可以继续进行。但是,如果不修改“my
interface A{ public void verifyCredentials(JsonObject credentials, Handler> handler); } @RunWith
我是否可以从 AsyncResult 中提取status?我正在编写一个功能测试,以确保所有路由工作并且需要输出状态。 最佳答案 您可以使用 transform 检查状态(但不能返回)方法: Asyn
场景 - 我有一个正在分配任务的进程池。但是,如果子进程在运行任务时被终止,AsyncResult 对象将永远不会被标记为就绪。我原本希望发生的是它会被标记为准备就绪但不成功。 重现这个: >>> i
我正在做一个演示,代码很简单: # The Config class Config: BROKER_URL = 'redis://127.0.0.1:6379/0' CELERY_RE
我将 celery 与 Flask 一起使用,我有以下任务: @celery.task(bind=True, max_retries=5) def failing_task(self): ti
我正在尝试获取任务的状态,如下所示: __init__.py celery = Celery(app.name,backend='amqp',broker=app.config['CELERY_BRO
我有一个正在运行的 WCF 服务,我在解决方案资源管理器中使用添加服务引用添加了对该服务的引用,并选中了创建异步操作的框。 我的调用工作正常,我有一个双向 channel 从服务器报告一些事件,我正在
我正在使用 celery 执行我的异步任务,我想要实现的是在我执行任务后获取工作流中每个任务的名称和 ID。 exec_workflow = chain( ta
问题是非常严重的内存泄漏,直到服务器崩溃(或者您可以通过终止 celery 工作服务来恢复,该服务会释放所有使用的 RAM) 在这个问题上似乎有一堆报告的错误,但很少有人关注这个警告,在 celery
我正在使用带有 redis 实现的 spring 缓存,我有以下方法 @Async @Cacheable(key = "#id") public Future getStudent(String id
我正在使用一个静态 URL 来启动一个长时间运行的后端进程(它通常按照 cron 计划进行,但我们希望能够手动启动它)。 下面的代码有效,当我手动测试时,我在浏览器中看到了结果。 @ResponseB
上下文:我对 Spring 非常陌生,以前从未使用过 @Async。我被指示根据电子邮件中发送给我的示例代码复制部分代码。 如果我要这样做,根据 @async 的文档和指南,我能知道的唯一方法是使用
我想使用 AsyncResult 对象重试之前撤销的任务,但收到一条错误消息,指出一旦运行该任务,该任务就会被丢弃 worker_1 | [2019-06-27 16:04:23,094: INFO/
我有一个用 Java 编写的 Play 2.1 Controller ,我需要调用一个外部网络服务来获取一些数据。然后根据这个数据结果,我必须用 n 个调用调用另一个 web 服务,对应于第一个 we
我有这个数据访问接口(interface): public interface UserDao { void loadUsers(Handler>> handler); } 它被用在这样的服务中
据我了解: 用户轮询 future 对象,直到结果可用。另一方面,作业是同步执行的,结果应该存储在某个地方直到下一次轮询。结果存储在哪里? 远程调用(即异步 SOAP 操作)是如何发生的?结果在服务器
我是一名优秀的程序员,十分优秀!