本文整理了Java中com.hazelcast.core.MultiMap.tryLock()
方法的一些代码示例,展示了MultiMap.tryLock()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MultiMap.tryLock()
方法的具体详情如下:
包路径:com.hazelcast.core.MultiMap
类名称:MultiMap
方法名:tryLock
[英]Tries to acquire the lock for the specified key.
If the lock is not available, then the current thread does not wait and the method returns false immediately.
Warning: This method uses hashCode and equals of the binary form of the key, not the actual implementations of hashCode and equals defined in the key's class.
[中]尝试获取指定密钥的锁。
如果锁不可用,则当前线程不等待,该方法立即返回false。
警告:此方法使用密钥二进制形式的hashCode和equals,而不是密钥类中定义的hashCode和equals的实际实现。
代码示例来源:origin: dCache/nfs4j
@Override
public void lockInterruptibly() throws InterruptedException {
locks.tryLock(key, Long.MAX_VALUE, TimeUnit.DAYS);
}
代码示例来源:origin: dCache/nfs4j
@Override
public boolean tryLock() {
return locks.tryLock(key);
}
代码示例来源:origin: dCache/nfs4j
@Override
public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
return locks.tryLock(key, time, unit);
}
代码示例来源:origin: hazelcast/hazelcast-jet
protected void handleMultiMapTryLock(String[] args) {
String key = args[1];
long time = (args.length > 2) ? Long.parseLong(args[2]) : 0;
boolean locked;
if (time == 0) {
locked = getMultiMap().tryLock(key);
} else {
try {
locked = getMultiMap().tryLock(key, time, TimeUnit.SECONDS);
} catch (InterruptedException e) {
currentThread().interrupt();
locked = false;
}
}
println(locked);
}
代码示例来源:origin: hazelcast/hazelcast-jet
protected void handleMultiMapTryLock(String[] args) {
String key = args[1];
long time = (args.length > 2) ? Long.parseLong(args[2]) : 0;
boolean locked;
if (time == 0) {
locked = getMultiMap().tryLock(key);
} else {
try {
locked = getMultiMap().tryLock(key, time, TimeUnit.SECONDS);
} catch (InterruptedException e) {
currentThread().interrupt();
locked = false;
}
}
println(locked);
}
代码示例来源:origin: com.hazelcast/hazelcast-all
protected void handleMultiMapTryLock(String[] args) {
String key = args[1];
long time = (args.length > 2) ? Long.parseLong(args[2]) : 0;
boolean locked;
if (time == 0) {
locked = getMultiMap().tryLock(key);
} else {
try {
locked = getMultiMap().tryLock(key, time, TimeUnit.SECONDS);
} catch (InterruptedException e) {
currentThread().interrupt();
locked = false;
}
}
println(locked);
}
代码示例来源:origin: com.hazelcast/hazelcast-all
protected void handleMultiMapTryLock(String[] args) {
String key = args[1];
long time = (args.length > 2) ? Long.parseLong(args[2]) : 0;
boolean locked;
if (time == 0) {
locked = getMultiMap().tryLock(key);
} else {
try {
locked = getMultiMap().tryLock(key, time, TimeUnit.SECONDS);
} catch (InterruptedException e) {
currentThread().interrupt();
locked = false;
}
}
println(locked);
}
内容来源于网络,如有侵权,请联系作者删除!