JDK-4089706 : java.lang.ThreadGroup.setMaxPriority() does not increase priority.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.4
  • CPU: sparc
  • Submitted: 1997-10-30
  • Updated: 1998-06-25
  • Resolved: 1998-06-25
Related Reports
Duplicate :  
Description

Name: akC45999			Date: 10/30/97




Using setMaxPriority() method, user can decrease group priority,
but cannot increase it, even to the previous value.

Such behaviour contradicts the specification.
 
------------------------------------- file setMaxPriority0102.java
// simplified version of the test
// javasoft.sqe.tests.api.java.lang.ThreadGroup.setMaxPriority0102;

import java.io.PrintStream;

public class setMaxPriority0102 {

  public static void main(String args[]) {
	ThreadGroup group=new ThreadGroup("setMaxPriority0102");

	for (int prio=Thread.MIN_PRIORITY; prio<=Thread.MAX_PRIORITY; prio++) {
		try {
			group.setMaxPriority(prio);
		} catch (Throwable e) {
			System.out.println("unexpected exception in setMaxPriority("+prio+"):"+e);
			return;
		}
		int prio1;
		try {
			prio1=group.getMaxPriority();
		} catch (Throwable e) {
			System.out.println("unexpected exception in setMaxPriority("+prio+"):"+e);
			return;
		}
		if (prio1!=prio) {
			System.out.println("setMaxPriority("+prio+"); getMaxPriority()="+prio1);
			return;
		}
	}
  }

} // end class setMaxPriority0102

------------------------------------- end of file setMaxPriority0102.java

Running the test:
novo64% javac setMaxPriority0102.java
novo64% setenv CLASSPATH .
novo64% java setMaxPriority0102
setMaxPriority(2); getMaxPriority()=1
novo64% 

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

Comments
EVALUATION The reporter is correct. joshua.bloch@Eng 1998-06-25
25-06-1998