Eclipse RCP:一次只运行一个作业? [英] Eclipse RCP: Only one Job runs at a time?

查看:213
本文介绍了Eclipse RCP:一次只运行一个作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

The Jobs API in Eclipse RCP apparently works much differently than I expected. I thought that creating and scheduling multiple Jobs would actually cause multiple worker threads to be created, executing the Jobs in parallel unless there was an ISchedulingRule conflict.

我回去读了文档更密切,并在JobManager类中发现了此注释:

I went back and read the documentation more closely, and also discovered this comment in the JobManager class:

/**
 * 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.
 */

现在看起来像我这样Job Manager只会试图使用一个后台工作线程。我完全错了吗?如果我是对的,

Now it looks to me like the Job manager will only ever attempt to use one background worker thread. Am I completely wrong about this? If I'm right,


  • 调度规则和锁的意义是什么?如果只有一个工作线程,作业不能相互预取。是否只有在调用Job的sleep()方法时才使用这些方法(例如,在持有锁时进行睡眠)?

  • 平台的任何部分都允许两个作业
  • what is the point of scheduling rules and locks? If there is only one worker thread, Jobs can never preemt each other. Wouldn't these only ever be used in case a Job's sleep() method is called (e.g. sleeping while holding a Lock)?
  • does any part of the platform allow two Jobs to actually run concurrently, on multiple worker threads, thus making the above features useful somehow?

我在这里缺少什么? ?

What am I missing here?

推荐答案

查看文档,特别是这部分:


作业可以选择异步完成
执行(在另一个
线程) / strong>,返回ASYNC_FINISH的结果状态
。完成
异步完成的作业必须通过调用setThread,
指定
执行线程,并且必须通过调用方法完成来指示
何时完成。

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 看起来很不自然。

这篇关于Eclipse RCP:一次只运行一个作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆