Adjust checkstyle rules. Make checkstyle fail the build when violations are found. Correct all current checkstyle violations.
This commit is contained in:
@ -5,14 +5,12 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
* 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 {
|
||||
@ -20,7 +18,8 @@ public class App {
|
||||
/**
|
||||
* Program entry point
|
||||
*
|
||||
* @param args command line args
|
||||
* @param args
|
||||
* command line args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
@ -35,7 +34,7 @@ public class App {
|
||||
producer.produce();
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
final Consumer consumer = new Consumer("Consumer_" + i, queue);
|
||||
|
@ -14,6 +14,9 @@ public class Consumer {
|
||||
this.queue = queue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Consume item from the queue
|
||||
*/
|
||||
public void consume() throws InterruptedException {
|
||||
|
||||
Item item = queue.take();
|
||||
|
@ -19,6 +19,9 @@ public class Producer {
|
||||
this.queue = queue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put item in the queue
|
||||
*/
|
||||
public void produce() throws InterruptedException {
|
||||
|
||||
Item item = new Item(name, itemId++);
|
||||
|
Reference in New Issue
Block a user