docs: update thread pool

This commit is contained in:
Ilkka Seppälä
2024-05-22 13:48:48 +03:00
parent 49dab27c85
commit 16fbd26a42
4 changed files with 138 additions and 102 deletions
@@ -25,6 +25,7 @@
package com.iluwatar.threadpool;
import java.util.concurrent.atomic.AtomicInteger;
import lombok.Getter;
/**
* Abstract base class for tasks.
@@ -33,7 +34,9 @@ public abstract class Task {
private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
@Getter
private final int id;
@Getter
private final int timeMs;
public Task(final int timeMs) {
@@ -41,14 +44,6 @@ public abstract class Task {
this.timeMs = timeMs;
}
public int getId() {
return id;
}
public int getTimeMs() {
return timeMs;
}
@Override
public String toString() {
return String.format("id=%d timeMs=%d", id, timeMs);
@@ -45,7 +45,7 @@ public class Worker implements Runnable {
try {
Thread.sleep(task.getTimeMs());
} catch (InterruptedException e) {
e.printStackTrace();
LOGGER.error("Error occurred: ", e);
}
}
}