T
- Type of resultpublic final class SyncScalar<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 UncheckedScalar
decorator. Or you may use
IoCheckedScalar
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.
Constructor and Description |
---|
SyncScalar(Scalar<T> src)
Ctor.
|
SyncScalar(Scalar<T> scalar,
Object lock)
Ctor.
|
Copyright © 2017–2019 Cactoos. All rights reserved.