Advertisement
Guest User

Untitled

a guest
Feb 13th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1.  public CashDesk getCashDesk(long maxWaitMillis) throws StoreServiceException {
  2.         locking.lock();
  3.         try {
  4.             if(semaphore.tryAcquire(maxWaitMillis, TimeUnit.MILLISECONDS)) { //// just Acquire (if no reason to try)
  5.                 return cashDesks.poll();
  6.             }
  7.         } catch (InterruptedException e) {
  8.             throw new StoreServiceException(e);
  9.         } finally {
  10.             locking.unlock();
  11.         }
  12.         throw new StoreServiceException("Maximum waiting time exceeded");
  13.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement