users@jaxb.java.net

RE: marshalling thread safety

From: Ernst, Matthias <matthias.ernst_at_coremedia.com>
Date: Sat, 16 Sep 2006 10:50:24 +0200

Trevor,

your marshaller thread isn't going to start running at some random point, right?
The application threads will somehow notify it to start marshalling through
some proper synchronization mechanism. That's when you establish the famous "happens-before"
relationship: "mutation"->"notification"->"wakeup"->"marshal". No extra synchronization
required for that.

You still need to coordinate the application threads, though.

Matthias


-----Original Message-----
From: Trevor Kramer [mailto:tkramer_at_hampshire.edu]
Sent: Fri 9/15/2006 22:55
To: users_at_jaxb.dev.java.net
Subject: marshalling thread safety
 
If I have a set of java classes annotated with @XmlAccessorType
(FIELD) which I need to access from multiple threads is there any way
other than throwing a giant lock around all accesses to the data
classes to ensure correct thread visibility? If I ensure that all
methods on the classes are synchronized this will make sure that all
threads using the classes see changes made by other threads - but If
I want to run a jaxb marshall in another thread since it uses
reflection does it grab each objects lock before reading the fields -
and if not then is there a way to ensure changes made by other
threads are visible to the jaxb thread without resorting to a giant
lock around all the classes?

Thanks,

Trevor

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net