BAEL-3855
This commit is contained in:
parent
dae03d6a87
commit
0692bac979
|
@ -14,8 +14,8 @@ public class SingleLock extends ConcurrentAccessExperiment {
|
||||||
|
|
||||||
protected Supplier<?> putSupplier(Map<String,String> map, int key) {
|
protected Supplier<?> putSupplier(Map<String,String> map, int key) {
|
||||||
return (()-> {
|
return (()-> {
|
||||||
try {
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
try {
|
||||||
return map.put("key" + key, "value" + key);
|
return map.put("key" + key, "value" + key);
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
@ -25,8 +25,8 @@ public class SingleLock extends ConcurrentAccessExperiment {
|
||||||
|
|
||||||
protected Supplier<?> getSupplier(Map<String,String> map, int key) {
|
protected Supplier<?> getSupplier(Map<String,String> map, int key) {
|
||||||
return (()-> {
|
return (()-> {
|
||||||
try {
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
try {
|
||||||
return map.get("key" + key);
|
return map.get("key" + key);
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
|
@ -17,8 +17,8 @@ public class StripedLock extends ConcurrentAccessExperiment {
|
||||||
return (()-> {
|
return (()-> {
|
||||||
int bucket = key % stripedLock.size();
|
int bucket = key % stripedLock.size();
|
||||||
Lock lock = stripedLock.get(bucket);
|
Lock lock = stripedLock.get(bucket);
|
||||||
try {
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
try {
|
||||||
return map.put("key" + key, "value" + key);
|
return map.put("key" + key, "value" + key);
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
@ -30,8 +30,8 @@ public class StripedLock extends ConcurrentAccessExperiment {
|
||||||
return (()-> {
|
return (()-> {
|
||||||
int bucket = key % stripedLock.size();
|
int bucket = key % stripedLock.size();
|
||||||
Lock lock = stripedLock.get(bucket);
|
Lock lock = stripedLock.get(bucket);
|
||||||
try {
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
try {
|
||||||
return map.get("key" + key);
|
return map.get("key" + key);
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
Loading…
Reference in New Issue