[vtkusers] a problem about multithread and VTK again

Jeff Lee jeff at cdnorthamerica.com
Sun Mar 31 08:43:59 EST 2002


Hi Lian,
How about sending us a piece of code which demonstrates the problem, 
then one of us can look at it and make some suggestions...  One piece of 
advice is to always make sure that your call to Render() in vtkPanel 
happens on the main awt thread.  This can be done by using 
SwingWorker.invokeLater(...).
-Jeff

lian jiang wrote:

> Hi, all: 
>
>          I  posted the mail once but did not receive any response. So 
> I have to post it again and hope someone can give me a help. Sorry to 
> bother you all.
>          I met a problem about VTK rendering window and multithread.  
> In my JAVA-VTK program, I have two button, A and B. In the method 
> associated with A, there is an infinite loop, in which the actors are 
> rendered from the first frame to last frame repeatedly in a rendering 
> window. I set a globale variable "boolean jump=false". The infinite 
> loop should exit by judging the value of "jump". In the method 
> associated with button B, I set the variable as true.
>         When I click A, the program will enter the infinite loop. I 
> intend to exit the loop whenever I click the button B. But here is a 
> problem. Once the program enters the dead loop, the GUI seems to be 
> stucked and cann't respond to any user action. So the method of B can 
> not set any global variable.
>          From the view of thread, it is easy to understand--because 
> the two buttons are both in the GUI thread, the dead loop will surely 
> block the GUI thread so that button B is disabled.    I tried to solve 
> the problem by multithread. Although the loop can exit as I imaged,  
> there still are some problems. If I put the dead loop in a thread, the 
> rendering window can not be refreshed. IF I put the method of B into a 
> thread, button B will also be disable once the program goes into the 
> dead loop.  I don't know whether it is a common problem for all kinds 
> of window refreshing.  I had studied multithread used in VTK for some 
> time. As far as I know, VTK window will cause some problems in 
> multithread because VTK calls opengl which is not safe for thread. But 
> I am not sure whether the refreshing problem described above is caused 
> by VTK or other reasons.  Is it a common problem for all kinds window 
> refreshing?  Is there a way to solve this problem?  Thank you very much.
>
>
> BEST WISHES
>
> Lian
>
>
> ------------------------------------------------------------------------
> *Do You Yahoo!?*
> Yahoo! Greetings <$rd_url/welcome/?http://greetings.yahoo.com> - send 
> greetings for Easter 
> <$rd_url/welcome/?http://greetings.yahoo.com/browse/Holidays/Easter/>, 
> Passover 
> <$rd_url/welcome/?http://greetings.yahoo.com/browse/Holidays/Passover/>






More information about the vtkusers mailing list