org.macrocloud.kernel.toolkit.utils.ThreadLocalUtil Maven / Gradle / Ivy
package org.macrocloud.kernel.toolkit.utils;
import org.springframework.lang.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
/**
* ThreadLocal 工具类,通过在ThreadLocal存储map信息,来实现在ThreadLocal中维护多个信息
*
e.g.
* ThreadLocalUtils.put("key",value);
* ThreadLocalUtils.get("key");
* ThreadLocalUtils.remove("key");
* ThreadLocalUtils.getAndRemove("key");
* ThreadLocalUtils.get("key",()->defaultValue);
* ThreadLocalUtils.clear();
*
*
* @author zhouhao
* @since 2.0
*/
@SuppressWarnings("unchecked")
public class ThreadLocalUtil {
/** The Constant LOCAL. */
private static final ThreadLocal
© 2015 - 2024 Weber Informatics LLC | Privacy Policy