gpt4 book ai didi

multithreading - eclipse RCP : Only one Job runs at a time?

转载 作者:行者123 更新时间:2023-12-04 06:39:32 26 4
gpt4 key购买 nike

Eclipse RCP 中的 Jobs API 的工作方式显然与我预期的大不相同。我认为创建和调度多个作业实际上会导致创建多个工作线程,并行执行作业,除非存在 ISchedulingRule 冲突。

我回去仔细阅读了文档,还在 JobManager 类中发现了这个注释:

/**
* Returns a running or blocked job whose scheduling rule conflicts with the
* scheduling rule of the given waiting job. Returns null if there are no
* conflicting jobs. A job can only run if there are no running jobs and no blocked
* jobs whose scheduling rule conflicts with its rule.
*/

现在在我看来,作业管理器只会尝试使用一个后台工作线程。我对此完全错了吗?如果我是对的,

  • 调度规则和锁有什么意义?如果只有一个工作线程,Jobs 永远无法相互抢占。难道这些不会只在 Job 的 sleep() 方法被调用时使用(例如,在持有锁时 sleep )吗?
  • 平台的任何部分是否允许两个作业实际上在多个工作线程上同时运行,从而使上述功能以某种方式有用?

我在这里错过了什么?

最佳答案

看看 documentation 中的运行方法,特别是这部分:

Jobs can optionally finish their execution asynchronously (in another thread) by returning a result status of ASYNC_FINISH. Jobs that finish asynchronously must specify the execution thread by calling setThread, and must indicate when they are finished by calling the method done.

ASYNC_FINISH 看起来很有趣。

关于multithreading - eclipse RCP : Only one Job runs at a time?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1871257/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com