Re: xpath, dom and multi threading
On 05/18/2010 03:58 PM, FrenKy wrote:
I'm building the DOM in a single thread and then I'm reading it in
several threads (usually not more then 20, depending on number of CPUs,
e.g. I'm running it sometimes on 100+ CPU machines).
Please provide an SSCCE.
<http://sscce.org/>
Without seeing what you're actually doing it is hard to know what you're doing
wrong.
But sometimes (seldom) I get NullPointer exception on most unexpected
locations during read operations... But _always_ when I've already built
XML. Threads are started after xml file is built. So I figured I'm doing
something wrong with multithreading and sync. Same application ran in
single threading mode does not throw NullPointerException.
Your description does not indicate what is wrong, but if the reading threads
are started from the same thread that build the DOM and only after the DOM is
completely constructed, and if nothing is changing the DOM, then threading is
not the problem.
But I guess from your answer I should take another look at how I'm doing
access to xml dom...
That is why I've asked if there is some thread safe implementation for
reading (guess I missed this part in my first post) xml DOM elements.
Once again, "[it] boils down to what you do to make any object model thread safe."
You didn't even describe your problem, much less show it, in your first post.
Now you've described your problem without showing it. With only a vague,
indirect description of your problem, one can only provide a vague, indirect
solution to it.
If it were a threading issue, then one would have to conclude that something
is altering your object model without proper synchronization after the threads
have started, or that they are started from a thread that does not have proper
synchronization with the thread that built the model. Otherwise it's not a
threading issue.
--
Lew