T
- Type of resultpublic final class Synced<T> extends Object implements Scalar<T>
This class implements Scalar
, which throws a checked
Exception
. This may not be convenient in many cases. To make
it more convenient and get rid of the checked exception you can
use the Unchecked
decorator. Or you may use
IoChecked
to wrap it in an IOException.
final List<Integer> list = new LinkedList<>();
final int threads = 100;
new RunsInThreads<>(
new SyncScalar<>(() -> list.add(1)), threads
); // list.size() will be equal to threads value
Objects of this class are thread-safe.
Copyright © 2017–2020 Cactoos. All rights reserved.