Here you can find the source of getDocumentBuilder()
private static DocumentBuilder getDocumentBuilder()
//package com.java2s; // Released under the terms of the CPL Common Public License version 1.0. import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; public class Main { private static final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); private static ThreadLocal<DocumentBuilder> documentBuilder = new ThreadLocal<DocumentBuilder>(); private static DocumentBuilder getDocumentBuilder() { DocumentBuilder builder = documentBuilder.get(); if (builder == null) { try { builder = documentBuilderFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new RuntimeException(e); }// w ww . j ava 2s . c om documentBuilder.set(builder); } return builder; } }