Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Diagnostics;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- Thread myThread = new Thread(func);
- myThread.Start();
- for (int i = 0; i < 1000; i++)
- {
- Console.WriteLine("Поток 1 выводит " + i);
- Thread.Sleep(0);
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Console.WriteLine("Runtime: " + ts.Milliseconds);
- Console.ReadLine();
- }
- static void func()
- {
- for (int i = 0; i < 1000; i++)
- {
- Console.WriteLine("Поток 2 выводит " + i.ToString());
- Thread.Sleep(0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement