Here you can find the source of put(ThreadLocal
private static void put(ThreadLocal<Map<Object, String>> threadLocal, Object key, String value)
//package com.java2s; import java.util.HashMap; import java.util.Map; public class Main { private static void put(ThreadLocal<Map<Object, String>> threadLocal, Object key, String value) { Map<Object, String> map = threadLocal.get(); if (map == null) { map = new HashMap<>(); }// w w w . j a v a2 s . c o m if (!map.containsKey(key)) { map.put(key, value); threadLocal.set(map); } } }