2015-05-31 11:55:18 +03:00
|
|
|
package com.iluwatar.threadpool;
|
2015-05-17 18:08:50 +03:00
|
|
|
|
2015-12-30 19:49:47 +01:00
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
2015-05-17 21:45:20 +03:00
|
|
|
/**
|
2015-12-30 19:49:47 +01: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 {
|
|
|
|
|
|
2015-12-30 19:49:47 +01:00
|
|
|
private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
|
2015-11-01 21:29:13 -05:00
|
|
|
|
|
|
|
|
private final int id;
|
|
|
|
|
private final int timeMs;
|
|
|
|
|
|
|
|
|
|
public Task(final int timeMs) {
|
2015-12-30 19:49:47 +01:00
|
|
|
this.id = ID_GENERATOR.incrementAndGet();
|
2015-11-01 21:29:13 -05:00
|
|
|
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
|
|
|
}
|