diff --git a/core-java/src/main/java/com/baeldung/concurrent/blockingqueue/BlockingQueueUsage.java b/core-java/src/main/java/com/baeldung/concurrent/blockingqueue/BlockingQueueUsage.java index 63c6cc4460..801dc4e35c 100644 --- a/core-java/src/main/java/com/baeldung/concurrent/blockingqueue/BlockingQueueUsage.java +++ b/core-java/src/main/java/com/baeldung/concurrent/blockingqueue/BlockingQueueUsage.java @@ -1,6 +1,5 @@ package com.baeldung.concurrent.blockingqueue; - import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; @@ -10,7 +9,6 @@ public class BlockingQueueUsage { int N_PRODUCERS = 4; int N_CONSUMERS = Runtime.getRuntime().availableProcessors(); - BlockingQueue queue = new LinkedBlockingQueue<>(BOUND); for (int i = 0; i < N_PRODUCERS; i++) { diff --git a/core-java/src/main/java/com/baeldung/concurrent/blockingqueue/NumbersConsumer.java b/core-java/src/main/java/com/baeldung/concurrent/blockingqueue/NumbersConsumer.java index 110a801acc..774c263a3b 100644 --- a/core-java/src/main/java/com/baeldung/concurrent/blockingqueue/NumbersConsumer.java +++ b/core-java/src/main/java/com/baeldung/concurrent/blockingqueue/NumbersConsumer.java @@ -1,9 +1,8 @@ package com.baeldung.concurrent.blockingqueue; - import java.util.concurrent.BlockingQueue; -class NumbersConsumer implements Runnable { +public class NumbersConsumer implements Runnable { private final BlockingQueue queue; public NumbersConsumer(BlockingQueue queue) { @@ -16,7 +15,6 @@ class NumbersConsumer implements Runnable { Integer number = queue.take(); String result = number.toString(); System.out.println(Thread.currentThread().getName() + " result: " + result); - } } catch (InterruptedException e) { Thread.currentThread().interrupt(); diff --git a/core-java/src/main/java/com/baeldung/concurrent/blockingqueue/NumbersProducer.java b/core-java/src/main/java/com/baeldung/concurrent/blockingqueue/NumbersProducer.java index c9e91cd077..dcc0b48453 100644 --- a/core-java/src/main/java/com/baeldung/concurrent/blockingqueue/NumbersProducer.java +++ b/core-java/src/main/java/com/baeldung/concurrent/blockingqueue/NumbersProducer.java @@ -1,20 +1,16 @@ package com.baeldung.concurrent.blockingqueue; - import java.util.Random; import java.util.concurrent.BlockingQueue; - -class NumbersProducer implements Runnable { +public class NumbersProducer implements Runnable { private final Random random = new Random(); private final BlockingQueue numbersQueue; - public NumbersProducer(BlockingQueue numbersQueue) { this.numbersQueue = numbersQueue; } - public void run() { try { generateNumbers();