-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
17, 18
-
b09
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
During refactoring, the priority was changed from Thread.MAX_PRIORITY - 2 to instead state Thread.MIN_PRIORITY - 2, which results in a negative priority, and is thus set to Thread.NORM_PRIORITY. Thus the Cleaner by default now has threads with priority 5, instead of 8.
The change was done in git revision # 992b50087d2ec8878dfcbbd1820a00b6b6bdf644 and label 8261036 by Claes Redestad
REGRESSION : Last worked in version 16.0.2
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the class below with Java 16.0.2 and Java 17
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
My cleaner thread priority is 8
ACTUAL -
My cleaner thread priority is 5
---------- BEGIN SOURCE ----------
import java.lang.ref.*;
public class CleanerDemo {
public static void main(String... args) throws InterruptedException {
Cleaner cleaner = Cleaner.create();
Cleaner.Cleanable cleanable = cleaner.register(new Object(),
() -> System.out.println("My cleaner thread priority is " +
Thread.currentThread().getPriority()));
System.gc();
Thread.sleep(1000);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
It is not a serious bug, since thread priorities are usually of not much significance. However, one could provide a thread factory with a different priority.
FREQUENCY : always
During refactoring, the priority was changed from Thread.MAX_PRIORITY - 2 to instead state Thread.MIN_PRIORITY - 2, which results in a negative priority, and is thus set to Thread.NORM_PRIORITY. Thus the Cleaner by default now has threads with priority 5, instead of 8.
The change was done in git revision # 992b50087d2ec8878dfcbbd1820a00b6b6bdf644 and label 8261036 by Claes Redestad
REGRESSION : Last worked in version 16.0.2
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the class below with Java 16.0.2 and Java 17
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
My cleaner thread priority is 8
ACTUAL -
My cleaner thread priority is 5
---------- BEGIN SOURCE ----------
import java.lang.ref.*;
public class CleanerDemo {
public static void main(String... args) throws InterruptedException {
Cleaner cleaner = Cleaner.create();
Cleaner.Cleanable cleanable = cleaner.register(new Object(),
() -> System.out.println("My cleaner thread priority is " +
Thread.currentThread().getPriority()));
System.gc();
Thread.sleep(1000);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
It is not a serious bug, since thread priorities are usually of not much significance. However, one could provide a thread factory with a different priority.
FREQUENCY : always
- duplicates
-
JDK-8273541 Cleaner Thread creates with normal priority instead of MAX_PRIORITY - 2
-
- Closed
-
- relates to
-
JDK-8261036 Reduce classes loaded by CleanerFactory initialization
-
- Resolved
-