Closed chunlaiqingke closed 2 months ago
没看懂问题
就是2个进程去拿锁,一个拿到锁,一个没拿到,我希望没拿到锁的进程阻塞,等锁的释放
如果不知道timeout弄多少,应该也可以自己在客户端用的时候封装一下
public void lock() { long start = System.currentTimeMillis(); while (!rheaKvLock.tryLock()) { if (System.currentTimeMillis() - start > 10 * 1000L) { log.warn("[JRaft RheaKV] try lock {} 10s", lockName); start = System.currentTimeMillis(); } try { TimeUnit.MILLISECONDS.sleep(100); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RheaKVException(e); } } log.warn("[JRaft RheaKV] try lock {} success", lockName); }
rt,这个分布式锁能实现阻塞等待吗,阻塞和唤醒的效果吗