Skip to content

Instantly share code, notes, and snippets.

@magicliang
Last active January 7, 2020 06:35
Show Gist options
  • Save magicliang/bebe002e95e6dee8be5336ea02ffaa7b to your computer and use it in GitHub Desktop.
Save magicliang/bebe002e95e6dee8be5336ea02ffaa7b to your computer and use it in GitHub Desktop.
一段 spring context 的 threadlocal 的用法
private final ThreadLocal<TestContext> testContextHolder = ThreadLocal.withInitial(
// Implemented as an anonymous inner class instead of a lambda expression due to a bug
// in Eclipse IDE: "The blank final field testContext may not have been initialized"
new Supplier<TestContext>() {
@Override
public TestContext get() {
return copyTestContext(TestContextManager.this.testContext);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment