-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathTask.java
More file actions
44 lines (36 loc) · 818 Bytes
/
Task.java
File metadata and controls
44 lines (36 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package threadpool;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author nemo
*/
public abstract class Task {
private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
private final int id;
private final int timeMs;
/**
* @param timeMs used by underlying task to calculate time neeeded
*/
public Task(final int timeMs) {
this.id = ID_GENERATOR.incrementAndGet();
this.timeMs = timeMs;
}
/**
* @return id
*/
public int getId() {
return id;
}
/**
* @return time needed
*/
public int getTimeMs() {
return timeMs;
}
/**
* @return task description
*/
@Override
public String toString() {
return String.format("id=%d timeMs=%d", id, timeMs);
}
}