users@jaxb.java.net

Re: JAXBContext and multithreading

From: Joe Fialli <joseph.fialli_at_sun.com>
Date: Fri, 10 Jan 2003 10:22:33 -0500

Martin Bosak wrote:
> Hello,
>
> Is it threadsafe to have multiple threads accessing the same JAXBContext
> object to obtain Marshallers and Unmarshallers? I have a schema where it
> literally takes over one minute to create a JAXBContext object (on a 1.6GH PC)?
> and I so I need to create one instance at process startup and
>cache it for later use during document processing.

Martin,

The specification nor javadoc explicitly states that a JAXBContext instance
must be thread-safe. However, the API was logically designed to be immutable
with this very purpose in mind. Once the JAXBContext object is created, there
is no exposed public API that modifies its logical state, namely the
set of XML Schemas that it is aware of and capable of unmarshalling,marshalling
or validating documents from.

So from a logical point of view, there is nothing exposed in the API
that would make the JAXBContext not thread-safe. We will examine
explicitly stating this in the next release of the specifcation.

Thanks again for your input,

-Joe Fialli, Sun Microsystems

>
> Thank You,
> Martin Bosak


--