Here you can find the source of newXPathFactory()
public static XPathFactory newXPathFactory()
//package com.java2s; //License from project: Apache License import javax.xml.xpath.*; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public class Main { private static final Lock factoryLock = new ReentrantLock(); public static XPathFactory newXPathFactory() { factoryLock.lock();/* w w w . j av a2 s . co m*/ try { return XPathFactory.newInstance(); } finally { factoryLock.unlock(); } } }