Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1.  
  2. public class CMain
  3. {
  4.     private boolean running = true;
  5.     private int threadNumber = 0;
  6.     public CMain()
  7.     {
  8.         Thread[] threads = new Thread[100];
  9.        
  10.         while(running)
  11.         {
  12.             if (threadNumber < 100)
  13.             {
  14.                 threads[threadNumber] = new Thread()
  15.                 {
  16.                     public void run()
  17.                     {
  18.                         int thread = threadNumber;
  19.                         while(running)
  20.                         {
  21.                             System.out.println(thread);
  22.                         }
  23.                     }
  24.                 };
  25.                 threads[threadNumber].start();
  26.                 threadNumber++;
  27.             }
  28.             else
  29.             {
  30.                 threadNumber++;
  31.                 if (threadNumber > 10000)
  32.                 {
  33.                     running = false;
  34.                 }
  35.             }
  36.             System.out.println("main");
  37.         }
  38.     }
  39.    
  40.     public static void main(String[] args)
  41.     {
  42.         new CMain();
  43.     }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement