Delete CoarseGrained.java
This commit is contained in:
parent
636e76ade0
commit
1470deb187
|
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue