using System.Collections.Generic;
public static void Main()
Random rnd = new Random();
Statistics stats = new();
var threads = new List<Thread>();
for( int i = 0; i < 10; i++ )
threads.Add(new Thread(() => {
Thread.Sleep(rnd.Next(100, 700)*10);
stats.Counter1.Increment();
threads.Add(new Thread(() => {
Thread.Sleep(rnd.Next(100, 700)*10);
stats.Counter2.Increment();
threads.ForEach(x => x.Start());
for(int a = 0; a < 50; a++)
Console.WriteLine(stats);
Console.WriteLine(stats);
for(int a = 0; a < 50; a++)
Console.WriteLine(stats);
foreach( var thread in threads ) thread.Join();
public sealed class Statistics
public Counter Counter1 {get;} = new Counter();
public Counter Counter2 {get;} = new Counter();
public override string ToString() => $"C1: {Counter1.Get()}, C2: {Counter2.Get()}";
public sealed class Counter
_ = Interlocked.Increment(ref _count);
_ = Interlocked.Exchange(ref _count, 0);