Wednesday, January 21, 2015

Setting the priority in java pgm



Setting the priority

public class Main
{
 public static void main(String[] args) throws Exception
{
      Thread thread1 = new Thread(new TestThread(1));
      Thread thread2 = new Thread(new TestThread(2));
      thread1.setPriority(Thread.Max_priority);
      thread2.setPriority(Thread.Min_priority);
      thread1.start();
      thread2.start();
      thread1.join();
      thread2.join();
      System.out.println("The priority has been set.");
   }
}

No comments:

Post a Comment