public long convert(long d, TimeUnit u) { return u.toMillis(d); } int excessNanos(long d, long m) { return 0; }
public long convert(long d, TimeUnit u) { return u.toMillis(d); } int excessNanos(long d, long m) { return 0; }
public long convert(long d, TimeUnit u) { return u.toMillis(d); } int excessNanos(long d, long m) { return 0; }
/** * Performs a <tt>Thread.sleep</tt> using this unit. * This is a convenience method that converts time arguments into the * form required by the <tt>Thread.sleep</tt> method. * @param timeout the maximum time to sleep. If less than * or equal to zero, do not sleep at all. * @throws InterruptedException if interrupted while sleeping. * @see java.lang.Thread#sleep */ public void sleep(long timeout) throws InterruptedException { if (timeout > 0) { long ms = toMillis(timeout); int ns = excessNanos(timeout, ms); Thread.sleep(ms, ns); } }
/** * Performs a <tt>Thread.sleep</tt> using this unit. * This is a convenience method that converts time arguments into the * form required by the <tt>Thread.sleep</tt> method. * @param timeout the maximum time to sleep. If less than * or equal to zero, do not sleep at all. * @throws InterruptedException if interrupted while sleeping. * @see java.lang.Thread#sleep */ public void sleep(long timeout) throws InterruptedException { if (timeout > 0) { long ms = toMillis(timeout); int ns = excessNanos(timeout, ms); Thread.sleep(ms, ns); } }
/** * Performs a <tt>Thread.sleep</tt> using this unit. * This is a convenience method that converts time arguments into the * form required by the <tt>Thread.sleep</tt> method. * @param timeout the maximum time to sleep. If less than * or equal to zero, do not sleep at all. * @throws InterruptedException if interrupted while sleeping. * @see java.lang.Thread#sleep */ public void sleep(long timeout) throws InterruptedException { if (timeout > 0) { long ms = toMillis(timeout); int ns = excessNanos(timeout, ms); Thread.sleep(ms, ns); } }
/** * Performs a timed <tt>Thread.join</tt> using this time unit. * This is a convenience method that converts time arguments into the * form required by the <tt>Thread.join</tt> method. * @param thread the thread to wait for * @param timeout the maximum time to wait. If less than * or equal to zero, do not wait at all. * @throws InterruptedException if interrupted while waiting. * @see java.lang.Thread#join(long, int) */ public void timedJoin(Thread thread, long timeout) throws InterruptedException { if (timeout > 0) { long ms = toMillis(timeout); int ns = excessNanos(timeout, ms); thread.join(ms, ns); } }
/** * Performs a timed <tt>Thread.join</tt> using this time unit. * This is a convenience method that converts time arguments into the * form required by the <tt>Thread.join</tt> method. * @param thread the thread to wait for * @param timeout the maximum time to wait. If less than * or equal to zero, do not wait at all. * @throws InterruptedException if interrupted while waiting. * @see java.lang.Thread#join(long, int) */ public void timedJoin(Thread thread, long timeout) throws InterruptedException { if (timeout > 0) { long ms = toMillis(timeout); int ns = excessNanos(timeout, ms); thread.join(ms, ns); } }
/** * Performs a timed <tt>Thread.join</tt> using this time unit. * This is a convenience method that converts time arguments into the * form required by the <tt>Thread.join</tt> method. * @param thread the thread to wait for * @param timeout the maximum time to wait. If less than * or equal to zero, do not wait at all. * @throws InterruptedException if interrupted while waiting. * @see java.lang.Thread#join(long, int) */ public void timedJoin(Thread thread, long timeout) throws InterruptedException { if (timeout > 0) { long ms = toMillis(timeout); int ns = excessNanos(timeout, ms); thread.join(ms, ns); } }
/** * Performs a timed <tt>Object.wait</tt> using this time unit. * This is a convenience method that converts timeout arguments * into the form required by the <tt>Object.wait</tt> method. * * <p>For example, you could implement a blocking <tt>poll</tt> * method (see {@link BlockingQueue#poll BlockingQueue.poll}) * using: * * <pre> public synchronized Object poll(long timeout, TimeUnit unit) throws InterruptedException { * while (empty) { * unit.timedWait(this, timeout); * ... * } * }</pre> * * @param obj the object to wait on * @param timeout the maximum time to wait. If less than * or equal to zero, do not wait at all. * @throws InterruptedException if interrupted while waiting. * @see java.lang.Object#wait(long, int) */ public void timedWait(Object obj, long timeout) throws InterruptedException { if (timeout > 0) { long ms = toMillis(timeout); int ns = excessNanos(timeout, ms); obj.wait(ms, ns); } }
/** * Performs a timed <tt>Object.wait</tt> using this time unit. * This is a convenience method that converts timeout arguments * into the form required by the <tt>Object.wait</tt> method. * * <p>For example, you could implement a blocking <tt>poll</tt> * method (see {@link BlockingQueue#poll BlockingQueue.poll}) * using: * * <pre> public synchronized Object poll(long timeout, TimeUnit unit) throws InterruptedException { * while (empty) { * unit.timedWait(this, timeout); * ... * } * }</pre> * * @param obj the object to wait on * @param timeout the maximum time to wait. If less than * or equal to zero, do not wait at all. * @throws InterruptedException if interrupted while waiting. * @see java.lang.Object#wait(long, int) */ public void timedWait(Object obj, long timeout) throws InterruptedException { if (timeout > 0) { long ms = toMillis(timeout); int ns = excessNanos(timeout, ms); obj.wait(ms, ns); } }
/** * Performs a timed <tt>Object.wait</tt> using this time unit. * This is a convenience method that converts timeout arguments * into the form required by the <tt>Object.wait</tt> method. * * <p>For example, you could implement a blocking <tt>poll</tt> * method (see {@link BlockingQueue#poll BlockingQueue.poll}) * using: * * <pre> public synchronized Object poll(long timeout, TimeUnit unit) throws InterruptedException { * while (empty) { * unit.timedWait(this, timeout); * ... * } * }</pre> * * @param obj the object to wait on * @param timeout the maximum time to wait. If less than * or equal to zero, do not wait at all. * @throws InterruptedException if interrupted while waiting. * @see java.lang.Object#wait(long, int) */ public void timedWait(Object obj, long timeout) throws InterruptedException { if (timeout > 0) { long ms = toMillis(timeout); int ns = excessNanos(timeout, ms); obj.wait(ms, ns); } }