Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
734 B
0
Indexable
Never
using System;
using System.Threading;

class Program
{
    static void Main(string[] args)
    {
        Random r = new Random();
        Thread t1 = new Thread(() =>
        {
            while (true)
            {
                int n = r.Next();
                Console.WriteLine("Thread 1: " + n);
                Thread.Sleep(r.Next(1000, 2000));
            }
        });
        Thread t2 = new Thread(() =>
        {
            while (true)
            {
                int n = r.Next();
                Console.WriteLine("Thread 2: " + n);
                Thread.Sleep(r.Next(1000, 2000));
            }
        });
        t1.Start();
        t2.Start();
        Console.ReadKey();
    }
}