Here you can find the source of newTransformerFactory()
public static TransformerFactory newTransformerFactory()
//package com.java2s; //License from project: Apache License import javax.xml.transform.*; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public class Main { private static final Lock factoryLock = new ReentrantLock(); public static TransformerFactory newTransformerFactory() { factoryLock.lock();// ww w.j a v a 2 s. c om try { return TransformerFactory.newInstance(); } finally { factoryLock.unlock(); } } }