Java examples for java.lang:ThreadLocal
get value from ThreadLocal
//package com.java2s; import java.util.Map; public class Main { public static void main(String[] argv) throws Exception { String attribute = "java2s.com"; System.out.println(get(attribute)); }// ww w .j a va 2 s .c om private static final ThreadLocal SESSION_MAP = new ThreadLocal(); public static Object get(String attribute) { Map map = (Map) SESSION_MAP.get(); return map.get(attribute); } public static <T> T get(String attribute, Class<T> clazz) { return (T) get(attribute); } }