<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def release(self):
 """ Release the currently held lock. In case the current thread holds no lock, a thread.error is thrown. """

        me = threading.currentThread()
        self.__condition.acquire()
        try:
            if self.__writer is me:
                self.__writer_lock_count -= 1
                if self.__writer_lock_count == 0:
                    self.__writer = None
                    self.__condition.notifyAll()
            elif me in self.__readers:
                self.__readers[me] -= 1
                if self.__readers[me] == 0:
                    del self.__readers[me]
                    if not self.__readers:
                        self.__condition.notifyAll()
            else:
                raise thread.error, "release unlocked lock"
        finally:
            self.__condition.release()