private FastMap newLocalMap() { // First, do some cleanup (remove dead threads). for (FastMap.Entry e = THREAD_TO_LOCAL_MAP.head(), end = THREAD_TO_LOCAL_MAP.tail(); (e = (FastMap.Entry) e.getNext()) != end; ) { Thread thread = (Thread) e.getKey(); if (!thread.isAlive()) { THREAD_TO_LOCAL_MAP.remove(thread); } } FastMap localMap = new FastMap(); THREAD_TO_LOCAL_MAP.put(Thread.currentThread(), localMap); return localMap; }