Write the program using Reentrant readwritelock
Task: How would i re write this using ReentrantReadWriteLock and why is it a better concurrency primitive to choose for the program?
public class Counter {
private int value;
public synchronized void increment() {
value++;
}
public synchronized void decrement() {
value--;
}
public int get() {
return value;
}
}
from Recent Questions - Stack Overflow https://ift.tt/34vF6kQ
https://ift.tt/eA8V8J
Comments
Post a Comment