refuge

直接上代码

    class Program
    {
        static readonly ConcurrentDictionary<string, Person> Dic = new ConcurrentDictionary<string, Person>();
        static void Main(string[] args)
        {
            for (int i = 0; i < 500; i++)
            {
                Task.Run(() => { GetPerson("wjire"); });
            }
            Console.ReadKey();
        }
        private static Person GetPerson(string key)
        {
            return Dic.GetOrAdd(key, k => new Person());
        }
    }

    class Person
    {
        public Person()
        {
            Console.WriteLine("new Person()");
        }
    }

 

输出:

 

WHAT FUCK!

哪位大佬能出来解释下么?有点懵逼啊!

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
相关资源
相似解决方案