1 28 29 package org.apache.commons.transaction.locking; 30 31 import org.apache.commons.transaction.util.LoggerFacade; 32 33 55 public class ReadWriteLock extends GenericLock { 56 57 public static final int NO_LOCK = 0; 58 59 public static final int READ_LOCK = 1; 60 61 public static final int WRITE_LOCK = 2; 62 63 71 public ReadWriteLock(Object resourceId, LoggerFacade logger) { 72 super(resourceId, WRITE_LOCK, logger); 73 } 74 75 89 public boolean acquireRead(Object ownerId, long timeoutMSecs) throws InterruptedException { 90 return acquire(ownerId, READ_LOCK, false, timeoutMSecs); 91 } 92 93 107 public boolean acquireWrite(Object ownerId, long timeoutMSecs) throws InterruptedException { 108 return acquire(ownerId, WRITE_LOCK, true, timeoutMSecs); 109 } 110 } | Popular Tags |