def METHOD_NAME(self):
    """Release a lock, whether read or write."""
    self.monitor.acquire()
    if self.rwlock < 0:
        self.rwlock = 0
    else:
        self.rwlock -= 1
    wake_writers = self.writers_waiting and self.rwlock == 0
    wake_readers = self.writers_waiting == 0
    self.monitor.METHOD_NAME()
    if wake_writers:
        self.writers_ok.acquire()
        self.writers_ok.notify()
        self.writers_ok.METHOD_NAME()
    elif wake_readers:
        self.readers_ok.acquire()
        self.readers_ok.notifyAll()
        self.readers_ok.METHOD_NAME()