BAEL-614 Added "public" to class definitions; Formatted code
This commit is contained in:
parent
955d26116c
commit
4ff894095c
|
@ -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<Integer> queue = new LinkedBlockingQueue<>(BOUND);
|
||||
|
||||
for (int i = 0; i < N_PRODUCERS; i++) {
|
||||
|
|
|
@ -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<Integer> queue;
|
||||
|
||||
public NumbersConsumer(BlockingQueue<Integer> 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();
|
||||
|
|
|
@ -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<Integer> numbersQueue;
|
||||
|
||||
|
||||
public NumbersProducer(BlockingQueue<Integer> numbersQueue) {
|
||||
this.numbersQueue = numbersQueue;
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
generateNumbers();
|
||||
|
|
Loading…
Reference in New Issue