-2
import com.sun.corba.se.spi.orbutil.threadpool.ThreadPool;
public class Game {
private boolean isAlive;
public static void main(String[] args) {
if(args.length !=2){
System.out.println("teste de thread");
System.out.println("testando");
}
int numTasks = Integer.parseInt(args[0]);
int numThreads = Integer.parseInt(args[1]);
ThreadPool threadPool = new ThreadPool(numThreads);
for(int i =0; i<numTasks; i++){
threadPool.runTask(createTask(i));
}
}
private static Runnable createTask(final int taskID){
return new Runnable(){
public void run(){
System.out.println("task "+taskID+": start");
try{
Thread.sleep(500);
}catch(InterruptedException rx){}
System.out.println("task "+taskID+": end");
}
}
}
}
Here has some options (not tested). But in your case, do not just see if the messages "task start" and "task end" are showing?
– hkotsubo
In this case the "task end" message will never appear because the threads are not interrupted. Interrupting a thread is an action that needs to be done explicitly and has nothing to do with the normal thread ending.
– Piovezan