Monday, June 30, 2014

isTerminated

package Algorithm;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class isTerminated {
@org.junit.Test
public void Test() {
ExecutorService a = Executors.newFixedThreadPool(20);
for (int i = 0; i <= 20; i++) {
a.execute(new terminated());


}
// false is returned if all task is completed
// true is returned if all task is completed and shut down Or shut down now is called
if(!a.isTerminated()){
System.out.println("Finished working ");
}

}

}

class terminated implements Runnable {

@Override
public void run() {
for (int i = 0; i <= 100000; i++) {
System.out.println("in");

}

}

}





No comments:

Post a Comment