Finished Thread Pool example code.
This commit is contained in:
27
thread-pool/src/main/java/com/iluwatar/Task.java
Normal file
27
thread-pool/src/main/java/com/iluwatar/Task.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.iluwatar;
|
||||
|
||||
public abstract class Task {
|
||||
|
||||
private static int nextId = 1;
|
||||
|
||||
private int id;
|
||||
private int timeMs;
|
||||
|
||||
public Task(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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user