public static boolean lock(SimpleRedisClient simpleRedisClient, String lockKey,int lockSeconds,int retryTimes) {
while(retryTimes-- >0) {
if(!isLock(simpleRedisClient, lockKey)) {
// 原子操作
if(simpleRedisClient.incr(lockKey,1, lockSeconds).intValue() ==1) {
return true;
}
simpleRedisClient.decr(lockKey,1, lockSeconds);
}
try {
Thread.sleep(100L);
}catch (InterruptedException var5) {
logger.error(var5.getMessage(), var5);
}
}
return false;
}