@@ -0,0 +1,1658 @@
+package com.bluecatcode.common.concurrent;%0A%0Aimport com.google.common.base.Optional;%0A%0Aimport javax.annotation.WillCloseWhenClosed;%0Aimport javax.annotation.WillNotClose;%0Aimport java.util.concurrent.TimeUnit;%0A%0A/**%0A * Specialised sleep methods%0A *%0A * @see TimeUnit%0A */%0Apublic class Sleep %7B%0A%0A    /**%0A     * Interruptible sleep of the current thread%0A     *%0A     * %3Cb%3EWill interrupt the thread if InterruptedException occurs%3C/b%3E%0A     *%0A     * @param timeout with unit, the maximum length of time that callers are willing to wait%0A     * @param unit with timeout, the maximum length of time that callers are willing to wait%0A     *%0A     * @see TimeUnit#sleep(long)%0A     */%0A    @WillCloseWhenClosed%0A    public static void sleepFor(long timeout, TimeUnit unit) %7B%0A        try %7B%0A            unit.sleep(timeout);%0A        %7D catch (InterruptedException e) %7B%0A            Thread.currentThread().interrupt();%0A        %7D%0A    %7D%0A%0A    /**%0A     * Uninterruptible sleep of the current thread%0A     *%0A     * %3Cb%3EWARNING: you must propagate the exception or interrupt the current thread%3C/b%3E%0A     *%0A     * @param timeout with unit, the maximum length of time that callers are willing to wait%0A     * @param unit with timeout, the maximum length of time that callers are willing to wait%0A     * @return true if was interrupted or false if not%0A     *%0A     * @see TimeUnit#sleep(long)%0A     */%0A    @WillNotClose%0A    public static Optional%3CInterruptedException%3E uninterruptibleSleepFor(long timeout, TimeUnit unit) %7B%0A        try %7B%0A            unit.sleep(timeout);%0A            return Optional.absent();%0A        %7D catch (InterruptedException e) %7B%0A            return Optional.of(e);%0A        %7D%0A    %7D%0A%7D%0A

Add Sleep