/** * Attempts to acquire in exclusive mode, aborting if interrupted, and failing * if the given timeout elapses. * * @param arg * the acquire argument. This value is conveyed to * {@link #tryAcquire} but is otherwise uninterpreted and can * represent anything you like. * @param id * * @param nanosTimeout * the maximum number of nanoseconds to wait * @return {@code true} if acquired; {@code false} if timed out * @throws InterruptedException * if the current thread is interrupted */ public final boolean tryAcquireNanos(int arg, Object id, long nanosTimeout) throws InterruptedException { if (Thread.interrupted()) throw new InterruptedException(); return tryAcquire(arg, id) || doAcquireNanos(arg, id, nanosTimeout); }