Finished Thread Pool example code.

This commit is contained in:
Ilkka Seppala
2015-05-17 18:08:50 +03:00
parent 4c0a300b86
commit 6e76227143
5 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,20 @@
package com.iluwatar;
public class Worker implements Runnable {
private Task task;
public Worker(Task task) {
this.task = task;
}
@Override
public void run() {
System.out.println(String.format("%s processing %s", Thread.currentThread().getName(), task.toString()));
try {
Thread.sleep(task.getTimeMs());
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}