对多个线程使用多个进度条而不干扰 GUI
我正在编写一个 Eclipse RCP 应用程序,其中多个线程将通过 GUI 中自己的进度条更新用户的进度。有人告诉我,允许每个人单独更新自己的进度条可能会导致共享资源(我认为进度条的父进度条之一,例如 Shell)发生冲突。这是真的吗?
有人建议我创建一个带有同步方法的中间类,该类将充当来自线程的更新调用的序列化漏斗。这是一个解决方案吗?您能提供更好的解决方案吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这实际上很容易。每当您需要从任何线程更新进度条时,您都可以将更新代码包含在
It is actually pretty easy. Whenever you need to update the progress bar from any of the threads, you enclose the update code in