Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using multiple progress bars for multiple threads without jamming the GUI

I am writing an Eclipse RCP application in which multiple threads will update the user on progress each through its own progress bar in the GUI. I have been told that to allow each to individually update its own progress bar is to potentially cause a conflict over a shared resource (one of the parent the progress bars such as the Shell, I suppose). Is this true?

It was suggested to me that I created an intermediary class with synchronized methods that will act as a serializing funnel for update calls from the threads. Is this a solution? Can you offer a better solution?

like image 575
Keith Pinson Avatar asked Jul 27 '11 19:07

Keith Pinson


1 Answers

It is actually pretty easy. Whenever you need to update the progress bar from any of the threads, you enclose the update code in

display.asyncExec(new Runnable() { .... });
like image 114
Tonny Madsen Avatar answered Oct 13 '22 09:10

Tonny Madsen