diff --git a/redisson/src/main/java/org/redisson/RedissonPriorityQueue.java b/redisson/src/main/java/org/redisson/RedissonPriorityQueue.java index ed64c50f3..a3992c877 100644 --- a/redisson/src/main/java/org/redisson/RedissonPriorityQueue.java +++ b/redisson/src/main/java/org/redisson/RedissonPriorityQueue.java @@ -273,19 +273,19 @@ public class RedissonPriorityQueue extends BaseRedissonList implements RPr return wrapLockedAsync(RedisCommands.LPOP, getRawName()); } - protected RFuture wrapLockedAsync(RedisCommand command, Object... params) { + protected final RFuture wrapLockedAsync(RedisCommand command, Object... params) { return wrapLockedAsync(() -> { return commandExecutor.writeAsync(getRawName(), codec, command, params); }); } protected final RFuture wrapLockedAsync(Supplier> callable) { - long threadId = Thread.currentThread().getId(); - CompletionStage f = lock.lockAsync(threadId).thenCompose(r -> { + long randomId = getServiceManager().generateValue(); + CompletionStage f = lock.lockAsync(randomId).thenCompose(r -> { RFuture callback = callable.get(); return callback.handle((value, ex) -> { CompletableFuture result = new CompletableFuture<>(); - lock.unlockAsync(threadId) + lock.unlockAsync(randomId) .whenComplete((r2, ex2) -> { if (ex2 != null) { if (ex != null) {