Trying to implement a Read-Write Lock, but get ConcurrencyViolationError

I think I solved the problem myself. In the constructor of ReadWriteLock, I should have related the Threads.Condition object with the ReentrantLock object as:

function ReadWriteLock()
    l = ReentrantLock()
    c = Threads.Condition(l)
    new(0, 0, false, l, c)
end

Now the program seems to work as expected!