#1021 enforce Checkstyle rules in the build

This commit is contained in:
Ilkka Seppälä
2019-11-16 16:00:24 +02:00
parent 9e58edf05e
commit 8747f1fd7a
17 changed files with 239 additions and 208 deletions

View File

@ -23,20 +23,22 @@
package com.iluwatar.producer.consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Producer Consumer Design pattern is a classic concurrency or threading pattern which reduces coupling between
* Producer and Consumer by separating Identification of work with Execution of Work.
* <p>
* In producer consumer design pattern a shared queue is used to control the flow and this separation allows you to code
* producer and consumer separately. It also addresses the issue of different timing require to produce item or
* consuming item. by using producer consumer pattern both Producer and Consumer Thread can work with different speed.
* Producer Consumer Design pattern is a classic concurrency or threading pattern which reduces
* coupling between Producer and Consumer by separating Identification of work with
* Execution of Work.
*
* <p>In producer consumer design pattern a shared queue is used to control the flow and this
* separation allows you to code producer and consumer separately. It also addresses the issue
* of different timing require to produce item or consuming item. by using producer consumer
* pattern both Producer and Consumer Thread can work with different speed.
*
*/
public class App {
@ -44,7 +46,7 @@ public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
* Program entry point
* Program entry point.
*
* @param args
* command line args

View File

@ -27,7 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Class responsible for consume the {@link Item} produced by {@link Producer}
* Class responsible for consume the {@link Item} produced by {@link Producer}.
*/
public class Consumer {
@ -43,12 +43,13 @@ public class Consumer {
}
/**
* Consume item from the queue
* Consume item from the queue.
*/
public void consume() throws InterruptedException {
Item item = queue.take();
LOGGER.info("Consumer [{}] consume item [{}] produced by [{}]", name, item.getId(), item.getProducer());
LOGGER.info("Consumer [{}] consume item [{}] produced by [{}]", name,
item.getId(), item.getProducer());
}
}

View File

@ -27,7 +27,7 @@ import java.util.Random;
/**
* Class responsible for producing unit of work that can be expressed as {@link Item} and submitted
* to queue
* to queue.
*/
public class Producer {
@ -45,7 +45,7 @@ public class Producer {
}
/**
* Put item in the queue
* Put item in the queue.
*/
public void produce() throws InterruptedException {