From 0692bac979c756b7e8a6e9fd95f37a58233e3f05 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 18 Mar 2020 10:18:58 +0100 Subject: [PATCH] BAEL-3855 --- .../main/java/com/baeldung/concurrent/lock/SingleLock.java | 4 ++-- .../main/java/com/baeldung/concurrent/lock/StripedLock.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core-java-modules/core-java-concurrency-collections-2/src/main/java/com/baeldung/concurrent/lock/SingleLock.java b/core-java-modules/core-java-concurrency-collections-2/src/main/java/com/baeldung/concurrent/lock/SingleLock.java index 19b3ba4510..4dff459df6 100644 --- a/core-java-modules/core-java-concurrency-collections-2/src/main/java/com/baeldung/concurrent/lock/SingleLock.java +++ b/core-java-modules/core-java-concurrency-collections-2/src/main/java/com/baeldung/concurrent/lock/SingleLock.java @@ -14,8 +14,8 @@ public class SingleLock extends ConcurrentAccessExperiment { protected Supplier putSupplier(Map map, int key) { return (()-> { + lock.lock(); try { - lock.lock(); return map.put("key" + key, "value" + key); } finally { lock.unlock(); @@ -25,8 +25,8 @@ public class SingleLock extends ConcurrentAccessExperiment { protected Supplier getSupplier(Map map, int key) { return (()-> { + lock.lock(); try { - lock.lock(); return map.get("key" + key); } finally { lock.unlock(); diff --git a/core-java-modules/core-java-concurrency-collections-2/src/main/java/com/baeldung/concurrent/lock/StripedLock.java b/core-java-modules/core-java-concurrency-collections-2/src/main/java/com/baeldung/concurrent/lock/StripedLock.java index 7adca428ba..47c47d8813 100644 --- a/core-java-modules/core-java-concurrency-collections-2/src/main/java/com/baeldung/concurrent/lock/StripedLock.java +++ b/core-java-modules/core-java-concurrency-collections-2/src/main/java/com/baeldung/concurrent/lock/StripedLock.java @@ -17,8 +17,8 @@ public class StripedLock extends ConcurrentAccessExperiment { return (()-> { int bucket = key % stripedLock.size(); Lock lock = stripedLock.get(bucket); + lock.lock(); try { - lock.lock(); return map.put("key" + key, "value" + key); } finally { lock.unlock(); @@ -30,8 +30,8 @@ public class StripedLock extends ConcurrentAccessExperiment { return (()-> { int bucket = key % stripedLock.size(); Lock lock = stripedLock.get(bucket); + lock.lock(); try { - lock.lock(); return map.get("key" + key); } finally { lock.unlock();