Reentrantlock works fine in Java but causes IllegalMonitorException in Scala
<p>I would like to migrate a Java function</p>

<pre><code>protected static final Lock LOCK = new ReentrantLock();
public double calculate(...){
    try {
        LOCK.tryLock(20, TimeUnit.SECONDS);
        ...
    }finally{
        LOCK.unlock()
    }
}
</code></pre>

<p>The same function in Scala:</p>

<pre><code>protected final def LOCK = new ReentrantLock
def calculate(...): double = {
    try{
        LOCK.tryLock(20, TimeUnit.Seconds)
        ...
    }finally{
        LOCK.unlock()
    }
}
</code></pre>

<p>The <code>LOCK.unlock()</code> is always causing a IllegalMonitorStateException. I dont see any reason why this is happpening. </p>

<p>Can someone tell me where the problem is?</p>