Search code examples
eclipsemultithreadingrcpjobs

how to achieve true concurrency with multiple eclipse rcp jobs


i have an eclipse rcp application that, from time to time, may have multiple jobs running at the same time. there are also cases where some of those jobs may need to be paused for a specified period of time. i noticed that while calling Thread.sleep() accomplishes that, it also seems to have some adverse effects on other jobs. i even get the (Not Responding) appearing on the app's header when i attempt to interact with UI. i mistakenly assumed that each job instance gets its own thread, but recently discovered that that was not the case. off the top of my head, the only thing i could think of is to explicitly create a Thread instance every time a job is created, and then set for the former to the latter via Job.setThread(). any feedback on this matter would be much appreciated! thank you for your time!


Solution

  • I would not advice to hack directly on the underlying threads since it's JobManager responsibility to manage the thread pool and the API declares no assumptions about that.

    Instead try to use the following Job' methods:

    #boolean sleep()
    #void wakeUp()
    #void join()
    

    The article "On the Job: The Eclipse Jobs API" may also help: http://www.eclipse.org/articles/Article-Concurrency/jobs-api.html