Probably the easiest way to parallelize would be to use parallel threads:
assocs.entrySet().parallelStream()
.forEach(e -> e.getValue().tick(e.getKey()));
But keep in mind that this will use ForkJoinPool.commonPoolto execute your threads, which has fewer threads than you have processors.
If you want to increase parallelism, you can always run your own ForkJoinPool
new ForkJoinPool(numberOfThreads).submit(() ->
assocs.entrySet().parallelStream()
.forEach(e -> e.getValue().tick(e.getKey())));
source
share