Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

12
LINES

< > TinyBrain | #1007379 - lockOrFail - try to acquire a Lock; fail after timeout

JavaX fragment (include)

1  
static void lockOrFail(Lock lock, long timeout) ctex {
2  
  ping();
3  
  if (!lock.tryLock(timeout, TimeUnit.MILLISECONDS)) {
4  
    S s = "Couldn't acquire lock after " + timeout + " ms.";
5  
    if (lock instanceof ReentrantLock) {
6  
      ReentrantLock l = cast lock;
7  
      s += " Hold count: " + l.getHoldCount() + ", owner: " + call(l, "getOwner");
8  
    }
9  
    fail(s);
10  
  }
11  
  ping();
12  
}

download  show line numbers  debug dex   

Travelled to 10 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1007379
Snippet name: lockOrFail - try to acquire a Lock; fail after timeout
Eternal ID of this version: #1007379/8
Text MD5: ced30a0de766bc061c2c7e0b11c325ca
Author: stefan
Category: javax / concurrency
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-11-01 03:37:30
Source code size: 385 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 176 / 200
Version history: 7 change(s)
Referenced in: [show]