Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { private final static ThreadLocal<StringBuilder> threadSafeStrBuilder = new ThreadLocal<StringBuilder>(); public static StringBuilder getThreadSafeStringBuilder() { StringBuilder sb = threadSafeStrBuilder.get(); if (sb == null) { sb = new StringBuilder(); threadSafeStrBuilder.set(sb); } sb.delete(0, sb.length()); return sb; } }