cactoos
cactoos copied to clipboard
reentrant lock
closes #1688
@fabriciofx take a look, please
@l3r8yJ
please, change the constructors to something like this:
public Synced(final Scalar<? extends T> scalar) {
this(scalar, new ReetrantLock());
}
public Synced(final Scalar<? extends T> scalar, final ReentrantLock lock) {
this.origin = scalar;
this.lock = lock;
}
(and the same to Synced
in Text
.
Another thing: can you provide a Test to measure the performance improvement (because now is parallel)?
Hello @l3r8yJ, what is the advantage of using this over the synchronized keyword? synchronized and reentrant locks are exactly the same semantically as far as I know.
The only difference is when using the new Java 21 virtual threads which does not support (yet) the synchronized keyword.
More details here: https://stackoverflow.com/a/11821900
@fabriciofx what's the point of these ktors? I don't see the point of this design.
can you explain, please?