Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- ExecutorService executorService = Executors.newFixedThreadPool(10);
- for (int i = 0; i < 10; i++) {
- CompletableFuture<String> stringCf = CompletableFuture.supplyAsync(() -> {
- try {
- System.out.println(Thread.currentThread().getName());
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println(Thread.currentThread().getName());
- return "done";
- }, executorService);
- // System.out.println(stringCf.get().toString()); if you add this it works
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement