It actually does start somewhat randomly - as an autosave mechanism
of the data model to local disk that kicks off on a timer every n
minutes - so if the serialization does not grab the object monitor
then I guess I need to guard all access to the data model with a
readwrite lock. I'm more concerned about thread visibility than I am
about a consistent snapshot (so if the serialization grabbed the
object monitor to guarantee that it saw the latest changes from other
threads that would work for me).
Trevor
On Sep 16, 2006, at 1:50 AM, Ernst, Matthias wrote:
> 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
>
>
> <winmail.dat>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net