Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132937 views
License: OTHER
1
public static void main(String[] args) throws
2
InterruptedException, ExecutionException {
3
ExecutorService pool =
4
Executors.newFixedThreadPool(4);
5
List<Future<String>> futures =
6
new ArrayList<Future<String>>();
7
8
for(int i = 0; i < 10; i++) {
9
futures.add(pool.submit(new StringTask(i)));
10
}
11
12
for(Future<String> future : futures){
13
String result = future.get();
14
System.out.println(result);
15
}
16
17
pool.shutdown();
18
}
19