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

Popular posts from this blog

I get wrong characters when retreiving the message body of an email using TIdIMAP4.UIDRetrieveTextPeek2()

How to drop the all the 1's in a correlation matrix

Today Walkin 14th-Sept