T - Type of result@Loggable(value=1) public final class Atomic<T> extends Object implements Callable<T>
This class runs your Callable in a concurrent thread-safe
manner, using a lock from Stateful.co. For example:
Callable<String> origin = new Callable<String>() {
@Override
public String call() {
// fetch it from a thread-critical resource
// and return
}
};
Lock lock = new RtSttc(new URN("urn:github:12345"), "token")
.locks().lock("test");
String result = new Atomic<String>(origin, lock).call();
If you want to use Runnable instead, try static method
Executors.callable(Runnable). If you
want to avoid checked exceptions, use callQuietly().
| Constructor and Description |
|---|
Atomic(Callable<T> clbl,
Lock lck)
Public ctor (default maximum waiting time of five minutes).
|
Atomic(Callable<T> clbl,
Lock lck,
String lbl)
Public ctor (default maximum waiting time of five minutes).
|
Atomic(Callable<T> clbl,
Lock lck,
String lbl,
long maximum)
Public ctor.
|
public Atomic(Callable<T> clbl, Lock lck)
clbl - Callable to uselck - Lock to usepublic Atomic(Callable<T> clbl, Lock lck, String lbl)
clbl - Callable to uselck - Lock to uselbl - Label to use for locking and unlocking (can be empty)public Atomic(Callable<T> clbl, Lock lck, String lbl, long maximum)
clbl - Callable to uselck - Lock to uselbl - Label to use for locking and unlocking (can be empty)maximum - Maximum waiting timeCopyright © 2014–2016 stateful.co. All rights reserved.