#502 Replaced usages of System.out with logger.
This commit is contained in:
@@ -22,6 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.doublechecked.locking;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -40,6 +43,8 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class App {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
*
|
||||
@@ -58,7 +63,7 @@ public class App {
|
||||
try {
|
||||
executorService.awaitTermination(5, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("Error waiting for ExecutorService shutdown");
|
||||
LOGGER.error("Error waiting for ExecutorService shutdown");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.doublechecked.locking;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -35,6 +38,8 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
*/
|
||||
public class Inventory {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Inventory.class);
|
||||
|
||||
private final int inventorySize;
|
||||
private final List<Item> items;
|
||||
private final Lock lock;
|
||||
@@ -57,8 +62,7 @@ public class Inventory {
|
||||
try {
|
||||
if (items.size() < inventorySize) {
|
||||
items.add(item);
|
||||
System.out.println(Thread.currentThread() + ": items.size()=" + items.size()
|
||||
+ ", inventorySize=" + inventorySize);
|
||||
LOGGER.info("{}: items.size()={}, inventorySize={}", Thread.currentThread(), items.size(), inventorySize);
|
||||
return true;
|
||||
}
|
||||
} finally {
|
||||
|
Reference in New Issue
Block a user