Delete CoarseGrained.java

This commit is contained in:
mguarnaccia 2020-03-11 11:20:37 +01:00 committed by GitHub
parent 636e76ade0
commit 1470deb187
1 changed files with 0 additions and 39 deletions

View File

@ -1,39 +0,0 @@
package com.baeldung.concurrent.lock;
import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;
import com.google.common.base.Supplier;
public class CoarseGrained extends ConcurrentAccessMap {
ReentrantLock lock;
public CoarseGrained(Map<String, String> map) {
super(map);
lock = new ReentrantLock();
}
protected Supplier<?> putSupplier(int x) {
return (()-> {
boolean done = false;
while(!done) {
done = lock.tryLock();
}
map.put("key" + x, "value" + x);
lock.unlock();
return null;
});
}
protected Supplier<?> getSupplier(int x) {
return (()-> {
boolean done = false;
while(!done) {
done = lock.tryLock();
}
map.get("key" + x);
lock.unlock();
return null;
});
}
}