Hi Tim,

"Tim Apessos" <[EMAIL PROTECTED]> wrote on 04/21/2006 01:45:14 AM:

> myCanvas.getUpdateManger().getUpdateRunnableQueue().invokeLater(new
>     Runnable() public void run() { performSVGUpdate1(); } });

> 1. Are multiple occurrences of code execution like this thread safe?

    Yes.

> 2. Is this simply placing all of the Runnable objects in a queue for the
> update manager to execute later?

    Yes, the invoke* methods simply add a runnable to a queue and wake
the runnableQueue's thread if it is sleeping.

> 3. Would it cause a problem if the update manager thread were running 
when
> we attempt to add another Runnable object to the queue?

    No (barring bugs).  The invokeLater/AndWait methods should be totally
thread safe, multiple threads should even be able to call the methods at 
the same time and not have anything blow up.  The running status of the
queue shouldn't come into in any way.

> Threads can be a source of great frustration to debug and I would like 
to
> get a better understanding of what is going on so I can prevent any
> conflicts before they happen. 

   Yes, they are currently one of the hardest topics for programmers
(memory management used to be one - especially for non-GC languages,
but the tools have gotten very good).  They are also likely to become
increasingly important now that virtually all processors are going
multi-core...

> When I write threads, I know exactly what is
> occurring and can prepare for it.  Here there are tools that are 
performing
> many methods for me and I am uncertain as to what precautions I should 
take.
> Any additional insight into the matter that I haven't mentioned 
regarding
> threads would be appreciated too.

   The reason behind the RunnableQueue is to provide synchronized
access to the DOM - exactly the same purpose as the Swing Event thread. 
The only thread that should ever read or write the DOM is the 
UpdateManager 
thread of the Document.

   The most common problem I have seen with the RunnableQueue (other than
people not using it to read/write to the DOM) is that if you do an
invokeAndWait call from the Swing thread there is a chance for deadlock
(some DOM methods require querying the Canvas which can only be done in 
the swing thread).


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to