Eclipse RCP:一次只运行一个作业?

编程入门 行业动态 更新时间:2024-10-08 20:36:23
本文介绍了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:一次只运行一个作业?

本文发布于:2023-11-24 00:45:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623353.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作业   Eclipse   RCP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!