Advertisement
This is comment for paste
Task for parallel processing
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Solution:
- ExecutorService executor = Executors.newFixedThreadPool(3);
- CompletableFuture.allOf(
- CompletableFuture.runAsync(() -> first.actions.stream()
- .sorted(Comparator.comparingInt(a -> a.priorityId))
- // .peek(a -> System.out.println("START: " + a.priorityId))
- .forEachOrdered(a -> processAction(first.entityId, a.priorityId, a.actionName)), executor),
- CompletableFuture.runAsync(() -> second.actions.stream()
- .sorted(Comparator.comparingInt(o -> o.priorityId))
- // .peek(a -> System.out.println("START: " + a.priorityId))
- .forEachOrdered(a -> processAction(second.entityId, a.priorityId, a.actionName)), executor)
- );
- executor.shutdown();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement