java.lang.IllegalMonitorStateException:当前线程不是锁的所有者

时间:2015-01-14 07:01:24

标签: java hazelcast

我将淡褐色从2.4升级到3.3,但发生了这种异常。

13:12:51,269 [Thread-21]: ERROR xx.xx.xxThread:1783 - run:
java.lang.IllegalMonitorStateException: Current thread is not owner of the lock! -> <not-locked>
    at com.hazelcast.concurrent.lock.operations.UnlockOperation.ensureUnlocked(UnlockOperation.java:71)
    at com.hazelcast.concurrent.lock.operations.UnlockOperation.unlock(UnlockOperation.java:65)
    at com.hazelcast.concurrent.lock.operations.UnlockOperation.run(UnlockOperation.java:57)
    at com.hazelcast.spi.impl.BasicOperationService$OperationHandler.handle(BasicOperationService.java:699)
    at com.hazelcast.spi.impl.BasicOperationService$OperationHandler.access$400(BasicOperationService.java:675)
    at com.hazelcast.spi.impl.BasicOperationService$OperationPacketHandler.handle(BasicOperationService.java:649)
    at com.hazelcast.spi.impl.BasicOperationService$OperationPacketHandler.handle(BasicOperationService.java:604)
    at com.hazelcast.spi.impl.BasicOperationService$OperationPacketHandler.access$1400(BasicOperationService.java:591)
    at com.hazelcast.spi.impl.BasicOperationService$BasicDispatcherImpl.dispatch(BasicOperationService.java:543)
    at com.hazelcast.spi.impl.BasicOperationScheduler$OperationThread.process(BasicOperationScheduler.java:439)
    at com.hazelcast.spi.impl.BasicOperationScheduler$OperationThread.doRun(BasicOperationScheduler.java:433)
    at com.hazelcast.spi.impl.BasicOperationScheduler$OperationThread.run(BasicOperationScheduler.java:408)
    at ------ End remote and begin local stack-trace ------.(Unknown Source)
    at com.hazelcast.spi.impl.BasicInvocationFuture.resolveApplicationResponse(BasicInvocationFuture.java:356)
    at com.hazelcast.spi.impl.BasicInvocationFuture.resolveApplicationResponseOrThrowException(BasicInvocationFuture.java:289)
    at com.hazelcast.spi.impl.BasicInvocationFuture.get(BasicInvocationFuture.java:181)
    at com.hazelcast.spi.impl.BasicInvocationFuture.get(BasicInvocationFuture.java:160)
    at com.hazelcast.spi.impl.BasicInvocationFuture.getSafely(BasicInvocationFuture.java:172)
    at com.hazelcast.concurrent.lock.LockProxySupport.unlock(LockProxySupport.java:126)
    at com.hazelcast.concurrent.lock.LockProxy.unlock(LockProxy.java:99)
    at activesync.server.CheckLoginsThread.run(CheckLoginsThread.java:1552)

3.3中getLock的更改是需要String作为新版本中的参数。我只是将它从Object更改为String,没有其他任何更改。代码如下:

Map logins = MyHazelcast.getMap("logins");
Lock lock = MyHazelcast.getLock("logins");
lock.lock();
try
{
     // do something...
}
finally
{
    lock.unlock();
}  

这是由新版本引起的还是我错过了什么?

1 个答案:

答案 0 :(得分:0)

> Current thread is not owner of the lock! -> <not-locked>

&#34;未锁定&#34;意味着找不到给定密钥的锁定。是否可以使用密钥锁定&#34;登录&#34;用在另一个地方?

也许您在代码中的某处释放了锁?

我会从这个锁的唯一键名开始。