Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public CashDesk getCashDesk(long maxWaitMillis) throws StoreServiceException {
- locking.lock();
- try {
- if(semaphore.tryAcquire(maxWaitMillis, TimeUnit.MILLISECONDS)) { //// just Acquire (if no reason to try)
- return cashDesks.poll();
- }
- } catch (InterruptedException e) {
- throw new StoreServiceException(e);
- } finally {
- locking.unlock();
- }
- throw new StoreServiceException("Maximum waiting time exceeded");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement