-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.0, 1.2.0
-
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);
}
}
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);
}
}
- duplicates
-
JDK-4089706 java.lang.ThreadGroup.setMaxPriority() does not increase priority.
-
- Closed
-
-
JDK-4189292 (thread spec) ThreadGroup and Thread need better and tighter specs
-
- Closed
-