mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-25 22:38:04 +02:00
misc
This commit is contained in:
parent
b7371b1ac2
commit
11f76e1a6e
4 changed files with 55 additions and 8 deletions
|
@ -0,0 +1,9 @@
|
|||
public final class StringTask implements Callable<String> {
|
||||
int id;
|
||||
public StringTask(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String call() {
|
||||
return "Run " + id;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
public static void main(String[] args) throws
|
||||
InterruptedException, ExecutionException {
|
||||
ExecutorService pool =
|
||||
Executors.newFixedThreadPool(4);
|
||||
List<Future<String>> futures =
|
||||
new ArrayList<Future<String>>();
|
||||
|
||||
for(int i = 0; i < 10; i++) {
|
||||
futures.add(pool.submit(new StringTask(i)));
|
||||
}
|
||||
|
||||
for(Future<String> future : futures){
|
||||
String result = future.get();
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
pool.shutdown();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue