public static void main(String[] args) throws Exception{
       

        long[] time;
        time = new long[10];
    
        Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
        int THREAD_COUNT = 10000;
        Thread threads[];
        threads = new Thread[THREAD_COUNT];
        
        Calculate calcs[];
        calcs = new Calculate[THREAD_COUNT];

        time[0] = System.currentTimeMillis();
        // Создаём 1000 потоков
        for (int i=0;i<THREAD_COUNT;i++)
        {
             Calculate calc = new Calculate();
             Thread t = new Thread(calc);
             threads[i] = t;
             t.setPriority(Thread.MIN_PRIORITY);
             calcs[i] = calc;
        }
        time[1] = System.currentTimeMillis();
        // запускаем 1000 потоков
        for (int i=0;i<THREAD_COUNT;i++)
        {
             threads[i].start();
        }
        //time[2] = System.currentTimeMillis();
        PerformanceTest.go = 1;
        // Засыпаем на секунду;
        time[2] = System.currentTimeMillis();
        Thread.sleep(1000);
        
        time[3] = System.currentTimeMillis();
        
        PerformanceTest.stop = 1;
        /*
        for (int i=0;i<THREAD_COUNT;i++)
        {
             threads[i].interrupt();
        }
        * */
        time[4] = System.currentTimeMillis();
        long res = 0;
        
        for (int i=0;i<THREAD_COUNT;i++)
        {
             //threads[i].interrupt();
             res += calcs[i].iterCount;
             
              if (res>Long.MAX_VALUE/2)
                System.out.println("WARNING!");
        }
        
         System.out.println(res/1000000);
         System.out.println("Time");
         
         for(int i = 0;i<5;i++)
                System.out.println(i+"="+time[i]);
             
        
    }