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);
}
}