import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
public class Main {
public static void main(String args[]) throws Exception{
ExecutorService es = Executors.newFixedThreadPool(3);
Future<Double> f = es.submit(new Avg());
Future<Integer> f2 = es.submit(new Factorial());
System.out.println(f.get());
System.out.println(f2.get());
es.shutdown();
}
}
class Avg implements Callable<Double> {
Avg() {
}
public Double call() {
return 0.0;
}
}
class Factorial implements Callable<Integer> {
Factorial() {
}
public Integer call() {
return 1;
}
}
|