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

ThreadGroup method setMaxPriority has two bugs

XMLWordPrintable

    • sparc
    • solaris_1, solaris_2.4

      Method setMaxPriority of class ThreadGroup is not consistent in
      its treatment of maximum priority relative to class Thread:

      (a) If the argument is less than Thread.MIN_PRIORITY, it should
          signal an IllegalArgumentException, not quietly replace the
          argument with Thread.MIN_PRIORITY.
      (b) Instead of requiring the maxPriority to decrease monotonically,
          it should allow the maxPriority to be set to any value not greater
          than the maxPriority of its parent.

      I recommend the following new definition:

          public final synchronized void setMaxPriority(int newMaxPriority) {
      checkAccess();
      if (newMaxPriority < MIN_PRIORITY) {
      throw new IllegalArgumentException();
      }
      int limit = (parent != null) ? parent.maxPriority : Thread.MAX_PRIORITY;
      if (newMaxPriority <= limit) {
      maxPriority = newMaxPriority;
      }
      for (int i = 0 ; i < ngroups ; i++) {
      groups[i].setMaxPriority(newMaxPriority);
      }
          }

            jjb Josh Bloch
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: