BAEL-614 Changed to use ThreadLocalRandom instead of Random
This commit is contained in:
parent
9308d7d54b
commit
fb61d1b187
|
@ -1,10 +1,10 @@
|
|||
package com.baeldung.concurrent.blockingqueue;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class NumbersProducer implements Runnable {
|
||||
private final Random random = new Random();
|
||||
|
||||
private final BlockingQueue<Integer> numbersQueue;
|
||||
|
||||
public NumbersProducer(BlockingQueue<Integer> numbersQueue) {
|
||||
|
@ -21,7 +21,7 @@ public class NumbersProducer implements Runnable {
|
|||
|
||||
private void generateNumbers() throws InterruptedException {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
numbersQueue.put(random.nextInt(100));
|
||||
numbersQueue.put(ThreadLocalRandom.current().nextInt(100));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue