Advertisement
Temabowl

Alpatov_lab_1

Apr 7th, 2020
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Diagnostics;
  7.  
  8. namespace ConsoleApp1
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. Stopwatch stopWatch = new Stopwatch();
  15. stopWatch.Start();
  16. Thread myThread = new Thread(func);
  17. myThread.Start();
  18. for (int i = 0; i < 1000; i++)
  19. {
  20. Console.WriteLine("Поток 1 выводит " + i);
  21. Thread.Sleep(0);
  22. }
  23.  
  24. stopWatch.Stop();
  25. TimeSpan ts = stopWatch.Elapsed;
  26.  
  27. Console.WriteLine("Runtime: " + ts.Milliseconds);
  28. Console.ReadLine();
  29. }
  30.  
  31. static void func()
  32. {
  33. for (int i = 0; i < 1000; i++)
  34. {
  35. Console.WriteLine("Поток 2 выводит " + i.ToString());
  36. Thread.Sleep(0);
  37. }
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement