This is an automated email from the ASF dual-hosted git repository.

fcsaky pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new 96b84258b6e [FLINK-36208][core] Use ThreadLocalRandom in AbstractID
96b84258b6e is described below

commit 96b84258b6edd1ddbe2fb55ef3542df0dd6d94de
Author: sullis <[email protected]>
AuthorDate: Tue Sep 17 09:01:21 2024 -0700

    [FLINK-36208][core] Use ThreadLocalRandom in AbstractID
---
 flink-core/src/main/java/org/apache/flink/util/AbstractID.java | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/flink-core/src/main/java/org/apache/flink/util/AbstractID.java 
b/flink-core/src/main/java/org/apache/flink/util/AbstractID.java
index f0d3849e058..f433030a6f7 100644
--- a/flink-core/src/main/java/org/apache/flink/util/AbstractID.java
+++ b/flink-core/src/main/java/org/apache/flink/util/AbstractID.java
@@ -20,7 +20,7 @@ package org.apache.flink.util;
 
 import org.apache.flink.annotation.PublicEvolving;
 
-import java.util.Random;
+import java.util.concurrent.ThreadLocalRandom;
 
 /** A statistically unique identification number. */
 @PublicEvolving
@@ -28,8 +28,6 @@ public class AbstractID implements Comparable<AbstractID>, 
java.io.Serializable
 
     private static final long serialVersionUID = 1L;
 
-    private static final Random RND = new Random();
-
     /** The size of a long in bytes. */
     private static final int SIZE_OF_LONG = 8;
 
@@ -86,8 +84,9 @@ public class AbstractID implements Comparable<AbstractID>, 
java.io.Serializable
 
     /** Constructs a new random ID from a uniform distribution. */
     public AbstractID() {
-        this.lowerPart = RND.nextLong();
-        this.upperPart = RND.nextLong();
+        ThreadLocalRandom random = ThreadLocalRandom.current();
+        this.lowerPart = random.nextLong();
+        this.upperPart = random.nextLong();
     }
 
     // 
--------------------------------------------------------------------------------------------

Reply via email to