Skip to content

Commit

Permalink
[FLINK-36208][core] Use ThreadLocalRandom in AbstractID
Browse files Browse the repository at this point in the history
  • Loading branch information
sullis authored Sep 17, 2024
1 parent 6cb9cb5 commit 96b8425
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@

import org.apache.flink.annotation.PublicEvolving;

import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;

/** A statistically unique identification number. */
@PublicEvolving
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;

Expand Down Expand Up @@ -86,8 +84,9 @@ public AbstractID(AbstractID id) {

/** 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();
}

// --------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 96b8425

Please sign in to comment.