From: "Brian W. Young" <[EMAIL PROTECTED]>
> I saw the original post here,
>
> But can someone in basic terms explain where there may be a threading
> issue?  We use dom4j as part of a fully threaded server and I'd like to
> know if there is anything I need to look out for.
>
> In many cases I use a shared dom4j document that many threads can read,
> but modification of course is done through proper synchronization in my
> own code.  Is this enough?  I think I'm hearing that it isn't.

One minor point. For optmisation, dom4j uses lazy evaluation; it tries for
example not to create List implementations until it absolutely has to. So if
you want to create a Document that is shared, in a read only state, across
many threads, I'd recommend using the NonLazyDocumentFactory (in the
org.dom4j.util package) to construct your documents. Its slower but should
avoid any issues caused by multi-threaded access to the same document
instance.

SAXReader reader = new SAXReader();
reader.setDocumentFactory(new NonLazyDocumentFactory());
Document safeDoc = reader.read( "foo.xml" );

James
-------
http://radio.weblogs.com/0112098/

>
> Thanks!
>
> Brain, Jim wrote:
>
> >I also echo a need to resolve this.  We are currently having this issue
in
> >production on a mission critical (probably everyone says that, but it is
an
> >app entry system for an insurance carrier, so I hope that qualifies)
> >application running on IBM OS/390 (ye old mainframe).  Before I pull the
> >HashTable version, I'd like to hear what the longer term plans are, since
> >there is a considerable ramp time on getting new cuts of code through our
> >integration management process.
> >
> >Jim
> >
> >
> >Jim Brain, [EMAIL PROTECTED]
> >"Researching tomorrow's decisions today."
> >(319) 369-2070 (work)
> >SYSTEMS ARCHITECT, ITS, AEGON FINANCIAL PARTNERS
> >
> > -----Original Message-----
> >From: David D. Lucas [mailto:ddlucas@;lse.com]
> >Sent: Tuesday, October 22, 2002 9:34 AM
> >To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> >Cc: Brain, Jim
> >Subject: Thread Safety
> >
> >Sorry for the cross post, but I have not seen any feedback on the thread
> >safety issues.  I have taken the stock CVS and changed all the HashMaps
> >to Hashtables to get things to work in our server environment.
> >
> >I would like to know what the long term direction is for thread safety
> >and if anyone would like my changes?
> >
> >Basically I took all the classes in org.dom4j.* and org.dom4j.tree.* and
> >changed them to use Hashtable.  The methods out there with
> >synchronization are probably no longer needed now that we have a
> >Hashtable.  I am looking at an alternative approach to keep the HashMap
> >and performance without having thread related failures.
> >
> >All this came from the QNameCache getting corrupted when two threads hit
> >  it at the same time.  It appears that one did a put while another did
> >a get and resulted in a null coming back.
> >
> >Please let me know what I should do next with the code.  If you want I
> >can post it or check it in (given access to development CVS).
> >
> >Thanks in advance,
> >Dave
> >
> >
> >
>
>
>
>
> -------------------------------------------------------
> This sf.net emial is sponsored by: Influence the future
> of Java(TM) technology. Join the Java Community
> Process(SM) (JCP(SM)) program now.
>
http://ad.doubleclick.net/clk;4699841;7576301;v?http://www.sun.com/javavote
> _______________________________________________
> dom4j-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


-------------------------------------------------------
This sf.net emial is sponsored by: Influence the future 
of Java(TM) technology. Join the Java Community 
Process(SM) (JCP(SM)) program now. 
http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0002en
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to