Package org.cactoos.scalar
Class Synced<T>
- java.lang.Object
-
- org.cactoos.scalar.Synced<T>
-
- Type Parameters:
T
- Type of result
- All Implemented Interfaces:
Scalar<T>
public final class Synced<T> extends Object implements Scalar<T>
Scalar that is thread-safe.This class implements
Scalar
, which throws a checkedException
. This may not be convenient in many cases. To make it more convenient and get rid of the checked exception you can use theUnchecked
decorator. Or you may useIoChecked
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.
- Since:
- 0.3