public static void Run(int max)
    {
        const int threadCount = 4;
        // This variable is used in multiple threads
        var sha1 = new Nest01();

        // BUG expected
        Action start = () => {
            for (int i = 0; i < max; i++)
            {
                var bytes = new byte[4];
                sha1.ComputeHash(bytes);
            }
        };
        var threads = Enumerable.Range(0, threadCount)
                      .Select(_ => new ThreadStart(start))
                      .Select(x => new Thread(x))
                      .ToList();

        foreach (var t in threads)
        {
            t.Start();
        }
        foreach (var t in threads)
        {
            t.Join();
        }
    }
Пример #2
0
 public Nest02()
 {
     _n = new Nest01();
 }