Threading and static methods in C#

后端 未结 3 1649
广开言路
广开言路 2021-02-19 20:54

Here is a meaningless extension method as an example:

public static class MyExtensions
{
    public static int MyExtensionMethod(this MyType e)
    {
        in         


        
3条回答
  •  梦毁少年i
    2021-02-19 21:28

    Yes, each thread gets its own separate local variable. This function will always return 2 even if called by multiple threads simultaneously.

提交回复
热议问题