public static void setThreadLocals( Map<CentralizedThreadLocal<?>, Object> longLivedThreadLocals, Map<CentralizedThreadLocal<?>, Object> shortLivedThreadLocals) { ThreadLocalMap threadLocalMap = _longLivedThreadLocals.get(); for (Map.Entry<CentralizedThreadLocal<?>, Object> entry : longLivedThreadLocals.entrySet()) { threadLocalMap.putEntry(entry.getKey(), entry.getValue()); } threadLocalMap = _shortLivedThreadLocals.get(); for (Map.Entry<CentralizedThreadLocal<?>, Object> entry : shortLivedThreadLocals.entrySet()) { threadLocalMap.putEntry(entry.getKey(), entry.getValue()); } }
@Override public T get() { ThreadLocalMap threadLocalMap = _getThreadLocalMap(); Entry entry = threadLocalMap.getEntry(this); if (entry == null) { T value = initialValue(); threadLocalMap.putEntry(this, value); return value; } else { return (T) entry._value; } }
@Override public void set(T value) { ThreadLocalMap threadLocalMap = _getThreadLocalMap(); threadLocalMap.putEntry(this, value); }