Does C# have a “ThreadLocal” analog (for data members) to the “ThreadStatic” attribute?

前端 未结 8 2262

I\'ve found the \"ThreadStatic\" attribute to be extremely useful recently, but makes me now want a \"ThreadLocal\" type attribute that lets me hav

8条回答
  •  忘掉有多难
    2020-12-14 09:03

    You should think about this twice. You are essentially creating a memory leak. Every object created by the thread stays referenced and can't be garbage collected. Until the thread ends.

提交回复
热议问题