Code example for ReentrantReadWriteLock

Methods: readLockwriteLock

0
    Lock readLock;
    Lock writeLock;
 
    public RequestManager(Map bookList) {
        this.bookList = bookList;
        lock = new ReentrantReadWriteLock();
        readLock = lock.readLock();
        writeLock = lock.writeLock();
    } 
 
    public String getBookList() {
        return ListRequest.execute(bookList, readLock);
    } 
 
    public String reserveBook(int bookID, int userID) {
        return ReserveRequest.execute(bookID, userID, bookList, writeLock);
    } 
 
    public String loanBook(int bookID, int userID) {
        return LoanRequest.execute(bookID, userID, bookList, writeLock);
Contextual code suggestions in your IDE  Get Codota for Java