creating new threads in a loop

前端 未结 2 1212
太阳男子
太阳男子 2020-12-12 01:30

I\'m trying to understand why this code is not working.

    private static object _lock;

    public static void Main (string[] args)
    {
        Thread th         


        
2条回答
  •  盖世英雄少女心
    2020-12-12 01:48

    Your lock does not do anything at all; only one thread is locking on that object - the one that is starting the others. Those other threads never contest for that lock at all.

提交回复
热议问题