Hi Dane

From: "Dane Foster" <[EMAIL PROTECTED]>
> Are there any caveats to using a single instance of a Document object
> between multiple Threads?

I've followed the Java Collections Framework (Java 2 Collections) on the
threading issues so far. Basically a Document is generally intended for
single threaded use.

However just like using List and Map implementations, if the collection is
static then it could be shared across threads - though as soon as you start
changing it in one thread then accessing it in another thread wierdness and
problems may well occur.

So a synchronized implementation may well be really useful that allows
minimal synchronization overhead but does allow valid concurrent
modification. (e.g. check out the FastHashMap implementation in the Jakarta
Commons 'collections' project).

One caveat is currently the DefaultElement implementation uses lazy creation
somewhat to minimise object construction so as 2 threads were to
concurrently navigate the same document then concurrent modification may
actually occur in the implementation which might cause a problem.

So we should make a non-lazy implementation of Element for use in
multi-threaded modes. Also a SynchronizedElement would be useful too. I'll
add these developments to our to do list...

James



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to