Here you can find the source of getMarshaller()
private static Marshaller getMarshaller() throws JAXBException
//package com.java2s; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; public class Main { private static JAXBContext jaxbContext; private static ThreadLocal<Marshaller> marshaller = new ThreadLocal<Marshaller>(); private static Marshaller getMarshaller() throws JAXBException { Marshaller m = marshaller.get(); if (m == null) { m = jaxbContext.createMarshaller(); marshaller.set(m);//from w ww .jav a2s . c o m } return m; } }