Create new JAXB Marshaller instance in static method… is it ThreadSafe?

后端 未结 1 432
生来不讨喜
生来不讨喜 2021-01-26 02:15

I have implemented a util class with the following static method:

public static String objToXml(JAXBContext jaxbContext, ClassA obj) throws Exception{
    Marsha         


        
相关标签:
1条回答
  • 2021-01-26 02:32

    Yes you must create a new Marshaller each time around if you are planning to use them multi-threaded.

    See Unofficial JAXB Guide

    The JAXBContext class is thread safe, but the Marshaller, Unmarshaller, and Validator classes are not thread safe.

    0 讨论(0)
提交回复
热议问题