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)

static void lockOrFail(Lock lock, long timeout) ctex {
  ping();
  if (!lock.tryLock(timeout, TimeUnit.MILLISECONDS)) {
    S s = "Couldn't acquire lock after " + timeout + " ms.";
    if (lock instanceof ReentrantLock) {
      ReentrantLock l = cast lock;
      s += " Hold count: " + l.getHoldCount() + ", owner: " + call(l, "getOwner");
    }
    fail(s);
  }
  ping();
}

download  show line numbers  debug dex   

Travelled to 3 computer(s): cfunsshuasjs, onxytkatvevr, 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: 48 / 86
Version history: 7 change(s)
Referenced in: [show]