zhangf
2024-08-08 71706ced3375f4c18148516d0477d8fd645de2ee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.gkhy.huataiFourierSpecialGasMonitor.utils;
 
import com.gkhy.huataiFourierSpecialGasMonitor.domain.account.entity.User;
 
/**
 * @author Mr.huang
 * @decription
 * @date 2023/7/11 13:38
 */
public class ThreadLocalUtil {
 
    public final static ThreadLocal<User> USER_THREAD_LOCAL = new ThreadLocal<>();
 
    //存入线程中
    public static void set(User user){
        USER_THREAD_LOCAL.set(user);
    }
 
    //从线程中获取
    public static User get(){
        return  USER_THREAD_LOCAL.get();
    }
 
    //将存入的数据移除
    public static void clear(){
        USER_THREAD_LOCAL.remove();
    }
}