FileDocCategorySizeDatePackage
PriorityThread.javaAPI DocExample2021Tue May 01 16:43:58 BST 2001None

PriorityThread

public class PriorityThread extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

        Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
        Thread t = Thread.currentThread();
        System.out.println(t);
        NewPriority hipri = new NewPriority(Thread.NORM_PRIORITY + 2);
        NewPriority lopri =new NewPriority(Thread.NORM_PRIORITY - 2);

        lopri.start();
        hipri.start();
      
          try
            {
              
             Thread.sleep(10000);
                 
             }
         catch(InterruptedException e)
             {
               System.out.println("Main thread interrupted.");
             }
         
        lopri.stop();
        hipri.stop();
                 
                   
         try
            {
              // Instruct main thread to wait for other threads to finish
              hipri.rt.join();
              lopri.rt.join();
       
             }
         catch(InterruptedException e)
             {
               System.out.println("Interupt exception caught");
             }
         
         System.out.println("low priority thread:   " + lopri.click);
         System.out.println("High priority thread:  " + hipri.click);