Untitled

 avatar
unknown
csharp
2 years ago
580 B
1
Indexable
using System;
using System.Threading;

class Program {
    static void Main(string[] args) {
        Thread t1 = new Thread(CountNumbers);
        Thread t2 = new Thread(CountNumbers);
        t1.Start();
        t2.Start();
        t1.Join();
        t2.Join();
        Console.WriteLine("Done counting.");
        Console.ReadLine();
    }

    static void CountNumbers() {
        for (int i = 1; i <= 10; i++) {
            Console.WriteLine("Thread " + Thread.CurrentThread.ManagedThreadId + ": " + i);
            Thread.Sleep(1000);
        }
    }
}