
public class Priority2 {

   long counter1 ;
   long counter2 ;

   public class RunMe1 implements Runnable {
      public void run() { while (true) counter1++ ; }
   }

   public class RunMe2 implements Runnable {
      public void run() { while (true) counter2++ ; }
   }


   public void doThis() {
      RunMe1 run1 = new RunMe1() ;
      RunMe2 run2 = new RunMe2() ;
      Thread t1 = new Thread(run1) ;
      Thread t2 = new Thread(run2) ;

      t1.setPriority( Thread.MAX_PRIORITY ) ;
      t2.setPriority( Thread.MIN_PRIORITY ) ;

      t1.start() ;
      t2.start() ;


      try { Thread.sleep(1000) ; } catch (Exception e) { }
         
      t2.stop() ;  // bad manners, don't do this
      t1.stop() ;  // bad manners, don't do this

      System.out.println("counter1 = " + counter1) ;
      System.out.println("counter2 = " + counter2) ;
   }


   public static void main (String [] args) {

      Priority2 obj = new Priority2() ;
      obj.doThis() ;

   }

}
