在 SCHEDULED 状态下取消 JavaFX 服务
Canceling JavaFX Service when in SCHEDULED state
我正在尝试使用 cancel()
方法取消我的 JavaFX Service
。
在调用 cancel()
之前,我检查了 Worker
状态。
System.out.println(service.getState());
System.out.println(service.cancel());
当 Worker
处于 SCHEDULED
状态时,cancel()
方法持续失败。 cancel()
returns false,Worker
进入 RUNNUNG
状态,然后终止为 SUCCEEDED
.
我在文档中找不到任何关于 cancel()
不影响 SCHEDULED
Worker
的内容。这是正常行为吗?
如果是这种情况,那么你应该file a bug report, as the behavior you describe directly contradicts the specified behavior in the Worker.State
javadoc。
A Worker may be cancelled when READY, SCHEDULED, or RUNNING, in which case the final status will be CANCELLED. When a Worker is cancelled in one of these circumstances it will transition immediately to the CANCELLED state.
Could it be some concurrency problem with my Task?
我希望有人回答有关您代码中潜在问题的问题,您需要编辑您的问题以提供 MCVE。
Is there any sources that outlines reasons for why a cancel() would fail?
javafx-src.zip is included in the Oracle Java 8 JRE,您可以调查源代码以确定其行为的一些原因。
我正在尝试使用 cancel()
方法取消我的 JavaFX Service
。
在调用 cancel()
之前,我检查了 Worker
状态。
System.out.println(service.getState());
System.out.println(service.cancel());
当 Worker
处于 SCHEDULED
状态时,cancel()
方法持续失败。 cancel()
returns false,Worker
进入 RUNNUNG
状态,然后终止为 SUCCEEDED
.
我在文档中找不到任何关于 cancel()
不影响 SCHEDULED
Worker
的内容。这是正常行为吗?
如果是这种情况,那么你应该file a bug report, as the behavior you describe directly contradicts the specified behavior in the Worker.State
javadoc。
A Worker may be cancelled when READY, SCHEDULED, or RUNNING, in which case the final status will be CANCELLED. When a Worker is cancelled in one of these circumstances it will transition immediately to the CANCELLED state.
Could it be some concurrency problem with my Task?
我希望有人回答有关您代码中潜在问题的问题,您需要编辑您的问题以提供 MCVE。
Is there any sources that outlines reasons for why a cancel() would fail?
javafx-src.zip is included in the Oracle Java 8 JRE,您可以调查源代码以确定其行为的一些原因。