@@ -36,8 +36,11 @@ public class RedisLockUtil {
boolean locked = false;
int tryCount = 3;
String threadId = String.valueOf(Thread.currentThread().getId());
- while (!locked && tryCount > 0) {
+ while (tryCount > 0) {
locked = redisTemplate.opsForValue().setIfAbsent(lockKey, threadId, expireTime, TimeUnit.SECONDS);
+ if(locked){
+ return locked;
+ }
tryCount--;
try {
Thread.sleep(300);