-
CSR
-
Resolution: Approved
-
P4
-
None
-
minimal
-
The ThreadLocalRandom class has just one private constructor, so it's not expected that there will be any sub-classes of this class, either in the JDK or external applications.
-
Java API
-
SE
Summary
Update the java.util.concurrent.ThreadLocalRandom to be a final class.
Problem
The ThreadLocalRandom class has a sole private constructor:
private ThreadLocalRandom() {
...
So in essence, the ThreadLocalRandom class cannot have any sub class. Marking the ThreadLocalRandom as final would thus convey it more clearly that the class cannot be extended.
Solution
Update the class to final
.
Specification
The proposed change looks as follows:
--- a/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java
+++ b/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java
@@ -93,7 +93,7 @@ import jdk.internal.misc.VM;
...
-public class ThreadLocalRandom extends Random {
+public final class ThreadLocalRandom extends Random {
- csr of
-
JDK-8283683 Make ThreadLocalRandom a final class
-
- Resolved
-