ThreadStatic Modified with Static C#
The ThreadStaticAttribute is only designed to be used on static variables, as the documentation points out. If you use it on an instance variable, I suspect it will do precisely nothing.
The ThreadStaticAttribute is only designed to be used on static variables, as the documentation points out. If you use it on an instance variable, I suspect it will do precisely nothing.
All of the answers here are correct, but a little disappointing as they somewhat gloss over how clever ThreadLocal‘s implementation is. I was just looking at the source code for ThreadLocal and was pleasantly impressed by how it’s implemented. The Naive Implementation If I asked you to implement a ThreadLocal<T> class given the API described … Read more