[vtkusers] Animation

PsyVis osue80 at bangor.ac.uk
Sun Nov 16 17:36:17 EST 2008


Thanks again Denis

I've used invokeAndWait() and that runs fine now - a bit slow. I'll get my
reading head on and read the pages about concurrency and hopefully be able
to get a a bit of speed up. 

Thanks again

Rich


Denis Barbier-5 wrote:
> 
> On 2008/11/16 PsyVis wrote:
>>
>> I've put everything inside the edt and lo and behold it works, but now
>> the
>> stop button is not recognized and if I try and shut the window nothing
>> responds.
> 
> Events are queued in the EDT and processed sequentially.  If you put
> a long running task in the EDT, user interface looks frozen until this
> task
> is finished, since no other event will be processed.  So what you describe
> now looks "normal".  You know now that previous crashes most certainly
> come from threading issues, and the solution is to take care of
> concurrency.
> Your code was
>      SwingUtilities.invokeLater(new Runnable() {
>            @Override
>            public void run() {
>                rp.getRenWin().Modified();
>                rp.getRenWin().Render();
>            }
>        });
> Here, you push a Runnable into the EDT, rp variable is known when this
> Runnable is created, so the compiler will add calls to Modified() and
> Render()
> methods on rp.getRenWin(), and processing in the main thread continues.
> But you do not know when this Runnable is going to be executed in the EDT,
> maybe instantaneously or maybe in 10 seconds, and the main thread
> continues
> its job, so it may modify rp before the Runnable has started.
> 
> The first solution is to replace invokeLater by invokeAndWait, then the
> main
> thread waits for the Runnable to finish before continuing.  This is very
> simple,
> but the main thread is blocked, so you will not have optimal performance.
> If you need better performance, this is a much harder task, you will have
> to
> learn about concurrency with Swing, see for instance
>     http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html
> 
> Denis
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 
> 

-- 
View this message in context: http://www.nabble.com/Animation-tp20524928p20530999.html
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list