2015-05-31 11:55:18 +03:00
|
|
|
package com.iluwatar.threadpool;
|
2015-05-17 18:08:50 +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 {
|
|
|
|
|
|
2015-11-01 21:29:13 -05:00
|
|
|
private static int nextId = 1;
|
|
|
|
|
|
|
|
|
|
private final int id;
|
|
|
|
|
private final int timeMs;
|
|
|
|
|
|
|
|
|
|
public Task(final int timeMs) {
|
|
|
|
|
this.id = nextId++;
|
|
|
|
|
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
|
|
|
}
|