Untitled

mail@pastecode.io avatar
unknown
plain_text
8 months ago
494 B
1
Indexable
Never
private void sendAllEmails(List<String> emails) throws InterruptedException {
    ExecutorService executorService;
    executorService = Executors.newFixedThreadPool(2);
    emails.forEach(email ->
            executorService.submit(() ->
                    sendEmail(email)));
    log.info("Tasks submitted...")
}


void printSum(Server server) {
     try {
         int sum = sendAllEmails(server);
         System.out.println("Sum: " + sum);
     } catch (InterruptedException e) {
     }
}
Leave a Comment