问题描述
我的 JSF 应用程序中的线程有问题,也许有人可以帮助我.
I have a problem with threads in my JSF application, maybe somebody could help me.
启动后,我运行新线程,该线程正在执行一些后台操作.该线程在while(true)
循环中工作,但是当它无能为力时,它将调用wait()
.之所以处于循环状态,是因为我必须在执行某些用户操作后调用notify()
.
After the start I run new thread which is making some background operations. This thread is working in while(true)
-loop but when there is nothing it can do it calls wait()
. It's working in loop because I have to call notify()
after some user actions.
现在我要完成的事情是:我希望线程通知主线程作业的一部分已经完成,因此我可以更新UI中的某些元素.有什么想法吗?
So now what I want to acomplish: I would like the thread to inform the main thread that the part of the job is finished, so I can update some elements in UI. Any ideas?
我也想显示FacesMessage,但是不可能从另一个线程显示(即使使用观察者模式)
I would also like to display FacesMessage, but it's imposible to do so from another thread (even using Observer pattern)
推荐答案
也许您可以使用ICEfaces服务器端推送进行异步后台工作来解决您的问题.
请查看 http://auctionmonitor.icefaces.org/auctionMonitor/auctionMonitor.jsf以推技术为例.
Maybe you can solve your problem with asynchronous background work with ICEfaces server side push.
Pleas take a look at http://auctionmonitor.icefaces.org/auctionMonitor/auctionMonitor.jsf for an example of the push technology.
您的后台工作线程可以执行推送",这将通知"某些页面进行更新(部分)并显示您的消息.
Your background working thread could perform a "push", which will "notify" certain pages to update (partially) and display your message.
这篇关于如何从另一个线程更新GUI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!