/** * Get the lock and increment the readers variable. */ protected void readerInc(String op) { // System.out.println("readerInc: "+lock.isLocked()+" "+readercnt); // let readers wait until no write operation is performed lock(); // lock2(); // System.out.println("reader enters: "+readercnt+" "+writeactions.size()); // readers.put(readercnt, op+": "+System.currentTimeMillis()); readercnt++; // unlock2(); unlock(); }
/** * Get the lock and decrement the readers variable. */ protected void readerDec() { // let readers wait until no write operation is performed lock(); // readers.remove(readercnt); readercnt--; if(readercnt==0) performWrites(); // else if(readercnt>1) // System.out.println("readers: "+readercnt);//+" "+readers); unlock(); }