, . 4- , .

,

ForkJoinPool threadPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors() * 2);

list.forEach(entry -> threadPool.execute(() -> {
    // processing
}));

if (!threadPool.awaitQuiescence(4, TimeUnit.MINUTES)) {
    // send alert about delay
}

, , , awaitQuiescence , . , - , ForkJoinPool?

+4
1

, , (list.forEach) . :

ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors() * 2);

pool.execute(() -> {
    list.parallelStream().forEach(item -> {
        // processing
    });
});

if (!pool.awaitQuiescence(4L, TimeUnit.MINUTES)) {
    // send alert about delay
}

( ), , ForkJoinPool .

0

Source: https://habr.com/ru/post/1648714/


All Articles