1 package org.jmage.util; 2 3 import java.util.HashMap; 4 import java.util.Map; 5 6 /*** 7 * Unsynchronized ThreadLocal HashMap 8 */ 9 public class ThreadLocalMap { 10 protected ThreadLocal threadLocalMap; 11 12 public ThreadLocalMap() { 13 threadLocalMap = new ThreadLocal(); 14 threadLocalMap.set(new HashMap()); 15 } 16 17 public void put(Object key, Object value) { 18 Map map = this.getHashMap(); 19 if(map==null) { 20 map = new HashMap(); 21 } 22 map.put(key, value); 23 this.threadLocalMap.set(map); 24 } 25 26 public Object get(Object key) { 27 return getHashMap().get(key); 28 } 29 30 public void remove(Object key) { 31 this.getHashMap().remove(key); 32 } 33 34 protected HashMap getHashMap() { 35 return (HashMap)threadLocalMap.get(); 36 } 37 }