SAX2: NSUtils.java

Toivo Lainevool tlainevool at yahoo.com
Wed Dec 15 17:48:47 GMT 1999


--- Miles Sabin <msabin at cromwellmedia.co.uk> wrote:
> David Megginson wrote,
> > I'm attaching a copy of the Java source code for the (short) 
> > NSUtils class that I described in the last message.  I'd be 
> > very grateful if the Java specialists on the list could look 
> > this over, paying special attention to synchronization 
> > problems.
> 
> I fear there are some big problems here. In particular,
... snip ...
> 	String name = (String)joinNameTable.get(qName);
... snip ...
> Is rather nastily thread-unsafe: the shared qName could be
> read/written by multiple threads in joinName(). You should
> either synchronize this method, or create a new QName locally.

Hashtable get() and put() are synchronized, so the read/write operations are
thread safe.  No need to have separate synchronized blocks.

The only problem I saw was the incrCounter method.  It increments and resests
the counter field.  This needs to be synchronized.  The easiest way would be to
make the incrCounter() method synchronized.

Toivo Lainevool
__________________________________________________
Do You Yahoo!?
Thousands of Stores.  Millions of Products.  All in one place.
Yahoo! Shopping: http://shopping.yahoo.com

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at ic.ac.uk the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)





More information about the Xml-dev mailing list