@Test public void testTryLock() { final MongoLockImpl m = new MongoLockImpl(mongo, dbName, collName, "l1", "c1", 1400, 400); System.out.println(null == null); try { if (m.tryLock()) { Thread t2 = new Thread() { public void run() { try { Assert.assertTrue(!m.tryLock()); } catch (InterruptedException e) { throw new RuntimeException(e); } }; }; t2.start(); t2.join(); } else { Assert.fail(); } } catch (InterruptedException e) { e.printStackTrace(); } finally { m.unlock(); } }
@Override public boolean tryLock() throws InterruptedException { if (llock.tryLock()) { if (!dlock.tryAcquire()) { llock.unlock(); return false; } else { logger.debug("try lock success, lock acquired"); return true; } } return false; }
MongoLockImpl implements ICMSLock { @Override public boolean tryLock() throws InterruptedException { if (llock.tryLock()) { if (!dlock.tryAcquire()) { llock.unlock(); return false; } else { logger.debug("try lock success, lock acquired"); return true; } } return false; } }
MongoLockImpl implements ICMSLock { @Override public boolean tryLock() throws InterruptedException { if (llock.tryLock()) { if (!dlock.tryAcquire()) { llock.unlock(); return false; } else { logger.debug("try lock success, lock acquired"); return true; } } return false; } MongoLockImpl(Mongo mongo, String dbName, String collName, String lockName, String clientName, int expireTime,
            int renewPeriod); }
MongoLockImpl implements ICMSLock { @Override public boolean tryLock() throws InterruptedException { if (llock.tryLock()) { if (!dlock.tryAcquire()) { llock.unlock(); return false; } else { logger.debug("try lock success, lock acquired"); return true; } } return false; } MongoLockImpl(Mongo mongo, String dbName, String collName, String lockName, String clientName, int expireTime,
            int renewPeriod); @Override void lock(); @Override boolean tryLock(); @Override synchronized void unlock(); }
MongoLockImpl implements ICMSLock { @Override public boolean tryLock() throws InterruptedException { if (llock.tryLock()) { if (!dlock.tryAcquire()) { llock.unlock(); return false; } else { logger.debug("try lock success, lock acquired"); return true; } } return false; } MongoLockImpl(Mongo mongo, String dbName, String collName, String lockName, String clientName, int expireTime,
            int renewPeriod); @Override void lock(); @Override boolean tryLock(); @Override synchronized void unlock();  }