Safiron

Verča - vlákna

Apr 13th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 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.        
  13.         static void SomeFunction(int x)
  14.         {
  15.             Console.WriteLine("Vlakno {0}", x);
  16.         }
  17.  
  18.         static void Main(string[] args)
  19.         {
  20.             List<Thread> threads = new List<Thread>();
  21.             for (int i = 0; i < 10; i++)
  22.             {
  23.                 threads.Add(new Thread(() => SomeFunction(i)));
  24.                 threads[i].Start();
  25.             }
  26.             Console.Read();
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment