Java tutorial
//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(); try { return XPathFactory.newInstance(); } finally { factoryLock.unlock(); } } }