#502 Replaced usages of System.out with logger.

This commit is contained in:
daniel-bryla
2016-10-23 19:59:03 +02:00
parent 4ca205c03c
commit 0438811489
154 changed files with 1155 additions and 792 deletions

View File

@ -22,6 +22,9 @@
*/
package com.iluwatar.threadpool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
@ -43,6 +46,8 @@ import java.util.concurrent.Executors;
*
*/
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
* Program entry point
@ -51,7 +56,7 @@ public class App {
*/
public static void main(String[] args) {
System.out.println("Program started");
LOGGER.info("Program started");
// Create a list of tasks to be executed
List<Task> tasks = new ArrayList<>();
@ -89,6 +94,6 @@ public class App {
while (!executor.isTerminated()) {
Thread.yield();
}
System.out.println("Program finished");
LOGGER.info("Program finished");
}
}

View File

@ -22,6 +22,9 @@
*/
package com.iluwatar.threadpool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* Worker implements {@link Runnable} and thus can be executed by {@link ExecutorService}
@ -29,6 +32,8 @@ package com.iluwatar.threadpool;
*/
public class Worker implements Runnable {
private static final Logger LOGGER = LoggerFactory.getLogger(Worker.class);
private final Task task;
public Worker(final Task task) {
@ -37,8 +42,7 @@ public class Worker implements Runnable {
@Override
public void run() {
System.out.println(String.format("%s processing %s", Thread.currentThread().getName(),
task.toString()));
LOGGER.info("{} processing {}", Thread.currentThread().getName(), task.toString());
try {
Thread.sleep(task.getTimeMs());
} catch (InterruptedException e) {