mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 12:59:00 +00:00
docs: update thread pool
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user