Files
java-design-patterns/thread-pool/src/main/java/com/iluwatar/threadpool/Task.java

35 lines
598 B
Java
Raw Normal View History

package com.iluwatar.threadpool;
2015-05-17 18:08:50 +03:00
import java.util.concurrent.atomic.AtomicInteger;
2015-05-17 21:45:20 +03:00
/**
*
2015-05-17 21:45:20 +03:00
* Abstract base class for tasks
*
*/
2015-05-17 18:08:50 +03:00
public abstract class Task {
private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
private final int id;
private final int timeMs;
public Task(final int timeMs) {
this.id = ID_GENERATOR.incrementAndGet();
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);
}
2015-05-17 18:08:50 +03:00
}