Safiron

Verča - vlákna 2

Apr 14th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Threading;
  7.  
  8. namespace DynamicThreads
  9. {
  10.     class Program
  11.     {
  12.         static int y = 0;
  13.  
  14.         static void SomeFunction()
  15.         {
  16.             y = 10;
  17.         }
  18.  
  19.         static void Main(string[] args)
  20.         {
  21.             for (int i = 0; i < 100; i++)
  22.             {
  23.                 y = 20;
  24.                 Thread thread = new Thread(SomeFunction);
  25.                 thread.Start();
  26.  
  27.                 Console.Write("{0} ", y);
  28.             }
  29.             Console.Read();
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment