Java tutorial
//package com.java2s; import java.util.Map; public class Main { private static final ThreadLocal<Map<Object, Object>> LOCAL_CACHE = new ThreadLocal<Map<Object, Object>>(); public static final void clear() { Map<Object, Object> cache = LOCAL_CACHE.get(); if (cache != null) { cache.clear(); LOCAL_CACHE.remove(); } } public static final Object get(Object key) { Map<Object, Object> cache = LOCAL_CACHE.get(); return cache == null ? null : cache.get(key); } public static final Object remove(Object key) { Map<Object, Object> cache = LOCAL_CACHE.get(); return cache == null ? null : cache.remove(key); } }