Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5073365

(thread) java.lang.Thread.SetPriority() raises a NullPointerException if a thread has exi

XMLWordPrintable

    • b43
    • generic, x86
    • linux, solaris, solaris_7, windows_2000

      Name: dk106046 Date: 07/13/2004

      Compile and run the following program.
      The setPriority method call will raise a NullPointerException.

      public class Npe extends java.lang.Thread {

          public void run(){
              try{
                  Thread.sleep(500);
              }catch(java.lang.InterruptedException e){}
          }

          public static void main(String[] args){
              Npe npe = new Npe();

              npe.start();
              try{
                  npe.join();
              }catch(java.lang.InterruptedException e){}

              npe.setPriority(java.lang.Thread.MIN_PRIORITY);
          }

      }

      The error message:

      Exception in thread "main" java.lang.NullPointerException
          at java.lang.Thread.setPriority(Thread.java:875)
          at Npe.main(Npe.java:18)

      obviously the line number in Thread.java will vary by build

      ======================================================================

            psoper Pete Soper (Inactive)
            dkorbel David Korbel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: