[jdom-interest] JDOM -- threads?
Edelson, Justin
Justin.Edelson at mtvn.com
Thu May 11 12:35:05 PDT 2006
Wikipedia has a reasonable definition of thread-safety:
http://en.wikipedia.org/wiki/Thread-safety
It's a bit of a simplification, but in practice, the fact that JDOM
isn't thread safe really means two things: don't edit a Document in one
thread while reading it in another thread and don't edit a Document in
multiple threads. If you have to do either of these, then you'll have to
provide your own syncronization. However, it's perfectly fine to edit a
Document, stop editing it, and then have multiple threads reading it.
(this is how I've always interpreted the use case "Single thread reads
an XML stream into JDOM and makes it available to a run time system for
read only access")
My guess it that if you don't know much about threads, you're not
building a multi-threaded application, so this may be moot for you.
Thread-safety is a big topic and I'd heartily recommend Doug Lea's
Concurrent Programming in Java book.
I'm not quite sure what you mean by "thread-related classes from system
API." It's possible that you could do something like this:
// get a document somehow
List contentList = document.getRootElement().getContent();
List syncList = Collections.syncronizedList(contentList);
// start a bunch of threads that could modify the syncList
But I haven't tried this myself.
-----Original Message-----
From: jdom-interest-bounces at jdom.org
[mailto:jdom-interest-bounces at jdom.org] On Behalf Of Frances
Sent: Thursday, May 11, 2006 2:23 PM
To: jdom-interest at jdom.org
Subject: [jdom-interest] JDOM -- threads?
just read in jdom.org that JDOM is not thread-safe.. what does this
mean exactly? (don't know much about threads..) that JDOM does not
include thread APIs, or that you can't do threads AT ALL with it? For
my project I have to be able to set threads...
(can I use thread-related classes from system API to make it
thread-safe?)
thanks..
Frances
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
More information about the jdom-interest
mailing list