are static classes shared among different threads in C#

前端 未结 5 1633
野性不改
野性不改 2021-02-14 11:44

I need to share a value between threads without exceeding it\'s boundary. Does a static variable do this?

5条回答
  •  灰色年华
    2021-02-14 12:04

    You decorate it with the ThreadStaticAttribute, to make the static variable share across only the thread it is initialized in.

    Static variables by default are across all threads in an AppDomain.

提交回复
热议问题