ThreadLocal在线程内部实现数据的共享
//编写ThreadLocalAPI
public class ThreadLocalUtil {
private static ThreadLocal thread = new ThreadLocal<>();
public static void set(User user) {
thread.set(user);
}
public static User get() {
return thread.get();
}
//防止内存泄漏问题
public static void remove() {
thread.remove();
}
}

相关文章:

  • 2022-12-23
  • 2021-05-13
  • 2022-01-01
  • 2021-11-04
  • 2021-10-31
  • 2022-01-01
  • 2021-12-28
猜你喜欢
  • 2021-11-10
  • 2021-08-17
  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
  • 2021-07-24
  • 2021-10-25
相关资源
相似解决方案