Skip to content

Instantly share code, notes, and snippets.

@seyedsahil
Created May 11, 2020 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seyedsahil/ca59b567fd71fad6d2aab445f289e3f6 to your computer and use it in GitHub Desktop.
Save seyedsahil/ca59b567fd71fad6d2aab445f289e3f6 to your computer and use it in GitHub Desktop.
Creating a ThreadLocal
public final class SessionContextHolder {
private static final SessionContextHolder sessionContextHolder;
static { sessionContextHolder = new SessionContextHolder(); }
public static SessionContextHolder getInstance() { return sessionContextHolder; }
private final ThreadLocal<Session> sessionContext;
private SessionContextHolder() {
super();
sessionContext = new ThreadLocal<>();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment