#502 Replaced usages of System.out with logger.
This commit is contained in:
@@ -23,6 +23,9 @@
|
||||
|
||||
package com.iluwatar.reader.writer.lock;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -48,6 +51,8 @@ import java.util.stream.IntStream;
|
||||
*/
|
||||
public class App {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
*
|
||||
@@ -71,7 +76,7 @@ public class App {
|
||||
try {
|
||||
executeService.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.reader.writer.lock;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
/**
|
||||
@@ -29,6 +32,8 @@ import java.util.concurrent.locks.Lock;
|
||||
*/
|
||||
public class Reader implements Runnable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Reader.class);
|
||||
|
||||
private Lock readLock;
|
||||
|
||||
private String name;
|
||||
@@ -55,8 +60,8 @@ public class Reader implements Runnable {
|
||||
*
|
||||
*/
|
||||
public void read() throws InterruptedException {
|
||||
System.out.println(name + " begin");
|
||||
LOGGER.info("{} begin", name);
|
||||
Thread.sleep(250);
|
||||
System.out.println(name + " finish");
|
||||
LOGGER.info("{} finish", name);
|
||||
}
|
||||
}
|
||||
|
@@ -22,6 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.reader.writer.lock;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
/**
|
||||
@@ -29,6 +32,8 @@ import java.util.concurrent.locks.Lock;
|
||||
*/
|
||||
public class Writer implements Runnable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Writer.class);
|
||||
|
||||
private Lock writeLock;
|
||||
|
||||
private String name;
|
||||
@@ -55,8 +60,8 @@ public class Writer implements Runnable {
|
||||
* Simulate the write operation
|
||||
*/
|
||||
public void write() throws InterruptedException {
|
||||
System.out.println(name + " begin");
|
||||
LOGGER.info("{} begin", name);
|
||||
Thread.sleep(250);
|
||||
System.out.println(name + " finish");
|
||||
LOGGER.info("{} finish", name);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user