Advertisement
Guest User

Untitled

a guest
Aug 14th, 2014
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. namespace test
  2. {
  3.     class MainClass
  4.     {
  5.         public volatile static int maxThreads = 1000;
  6.         public volatile static int currentThreads = 0;
  7.  
  8.         public static void Main (string[] args)
  9.         {
  10.             while (true) {
  11.  
  12.                 for (int i = 0; i < maxThreads - currentThreads; ++i) {
  13.                     Thread t = new Thread (new ThreadStart (bla));
  14.                     t.IsBackground = true;
  15.                     t.Start ();
  16.                 }
  17.  
  18.                 Console.WriteLine (currentThreads);
  19.  
  20.                 Thread.Sleep(100);
  21.             }
  22.         }
  23.  
  24.         public static void bla()
  25.         {
  26.             currentThreads++;
  27.  
  28.             currentThreads--;
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement