X
- The type to itetare overpublic final class ForEachInThreads<X> extends Object implements Proc<Iterable<X>>
Proc
in a new Thread for each element of an
Iterable
This class can be effectively used to iterate through a collection, just like
Stream.forEach(java.util.function.Consumer)
works,
but with no guarantee on the output sorting:
new ForEachInThreads(
new ProcOf<>(input -> System.out.printf("\'%s\' ", input)),
).execute(
new IterableOf<>("Mary", "John", "William", "Napkin")
); // Will print 'Mary' 'John' 'William' 'Napkin' to standard output.
// Order of printing can be random.
There is no thread-safety guarantee.
Constructor and Description |
---|
ForEachInThreads(Proc<X> proc)
Ctor.
|
Copyright © 2017–2020 Cactoos. All rights reserved.