|
@@ -35,7 +35,7 @@ public class RedisLockUtil {
|
|
|
public boolean lock(String lockKey, int expireTime) {
|
|
|
boolean locked = false;
|
|
|
int tryCount = 3;
|
|
|
- long threadId = Thread.currentThread().getId();
|
|
|
+ String threadId = String.valueOf(Thread.currentThread().getId());
|
|
|
while (!locked && tryCount > 0) {
|
|
|
locked = redisTemplate.opsForValue().setIfAbsent(lockKey, threadId, expireTime, TimeUnit.MILLISECONDS);
|
|
|
tryCount--;
|
|
@@ -55,7 +55,7 @@ public class RedisLockUtil {
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean unlock(String lockKey) {
|
|
|
- Long threadId = Thread.currentThread().getId();
|
|
|
+ String threadId = String.valueOf(Thread.currentThread().getId());
|
|
|
if (StrUtil.isEmpty(lockKey) || Objects.isNull(threadId))
|
|
|
return false;
|
|
|
boolean releaseLock = false;
|
|
@@ -73,7 +73,7 @@ public class RedisLockUtil {
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean unlockLua(String lockKey) {
|
|
|
- Long threadId = Thread.currentThread().getId();
|
|
|
+ String threadId = String.valueOf(Thread.currentThread().getId());
|
|
|
if (StrUtil.isEmpty(lockKey) || Objects.isNull(threadId))
|
|
|
return false;
|
|
|
DefaultRedisScript<Long> redisScript = new DefaultRedisScript();
|