Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static LinkedHashSet<BigInteger> locks = new LinkedHashSet<BigInteger>();
- private static final ReentrantLock lock = new ReentrantLock();
- private boolean acquireLock(BigInteger tr)
- {
- lock.lock();
- try{
- if (locks.contains(tr)){
- return false;
- } else {
- locks.add(tr);
- return true;
- }
- }finally
- {
- lock.unlock();
- }
- }
- private void releaseLock(BigInteger tr)
- {
- lock.lock();
- try
- {
- locks.remove(tr);
- } finally
- {
- lock.unlock();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement