alibaba / transmittable-thread-local

📌 a missing Java std lib(simple & 0-dependency) for framework/middleware, provide an enhanced InheritableThreadLocal that transmits values between threads even using thread pooling components.
https://github.com/alibaba/transmittable-thread-local
Apache License 2.0
7.59k stars 1.69k forks source link

TransmittableThreadLocal override static java.lang.ThreadLocal#withInitial method #315

Closed Razor0719 closed 2 years ago

Razor0719 commented 2 years ago

when I use the TransmittableThreadLocal first, I use it with code below:

TransmittableThreadLocal.withInitial(() -> "A");

and then I use ttl javaangent with the program, and found the value in ttl was never transfer into the sub thread, suddenly, I find the method 'withInitial()' is not override in TransmittableThreadLocal but construct a SuppliedThreadLocal which is extended from ThreadLocal

can TransmittableThreadLocal override this method and then avoid my mistake

oldratlee commented 2 years ago

Good point!

I'm adding the TransmittableThreadLocal.withInitial() static method and release a new version these days.

Thanks for your professional suggestion. @Razor0719

oldratlee commented 2 years ago

@Razor0719 released v2.12.2

https://github.com/alibaba/transmittable-thread-local/releases/tag/v2.12.2

Razor0719 commented 2 years ago

@Razor0719 released v2.12.2

https://github.com/alibaba/transmittable-thread-local/releases/tag/v2.12.2

thanks a lot!