We have a concurrent package, and JRE locks live in a similar package,
so let's put our new code in there.
This commit is contained in:
parent
7ba418fc6f
commit
fc686a48ef
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.commons.lang3;
|
package org.apache.commons.lang3.concurrent;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.locks.StampedLock;
|
import java.util.concurrent.locks.StampedLock;
|
||||||
|
@ -24,7 +24,8 @@ import org.apache.commons.lang3.function.FailableConsumer;
|
||||||
import org.apache.commons.lang3.function.FailableFunction;
|
import org.apache.commons.lang3.function.FailableFunction;
|
||||||
|
|
||||||
|
|
||||||
/** Utility class for working with {@link java.util.concurrent.locks.Lock locked objects}. Locked objects are an
|
/**
|
||||||
|
* Utility class for working with {@link java.util.concurrent.locks.Lock locked objects}. Locked objects are an
|
||||||
* alternative to synchronization.
|
* alternative to synchronization.
|
||||||
*
|
*
|
||||||
* Locking is preferable, if there is a distinction between read access (multiple threads may have read
|
* Locking is preferable, if there is a distinction between read access (multiple threads may have read
|
||||||
|
@ -64,8 +65,10 @@ import org.apache.commons.lang3.function.FailableFunction;
|
||||||
* lock.runWriteLocked((ps) -> { ps.write(buffer); ps.println(); });
|
* lock.runWriteLocked((ps) -> { ps.write(buffer); ps.println(); });
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
|
* @since 3.11
|
||||||
*/
|
*/
|
||||||
public class Locks {
|
public class Locks {
|
||||||
|
|
||||||
public static class Lock<O extends Object> {
|
public static class Lock<O extends Object> {
|
||||||
private final O lockedObject;
|
private final O lockedObject;
|
||||||
private final StampedLock lock = new StampedLock();
|
private final StampedLock lock = new StampedLock();
|
|
@ -14,13 +14,14 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.commons.lang3;
|
package org.apache.commons.lang3.concurrent;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.util.function.LongConsumer;
|
import java.util.function.LongConsumer;
|
||||||
|
|
||||||
import org.apache.commons.lang3.Locks.Lock;
|
import org.apache.commons.lang3.concurrent.Locks;
|
||||||
|
import org.apache.commons.lang3.concurrent.Locks.Lock;
|
||||||
import org.apache.commons.lang3.function.FailableConsumer;
|
import org.apache.commons.lang3.function.FailableConsumer;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
Loading…
Reference in New Issue