package com.flowpowered.commons;

import java.io.IOException;
import java.io.InputStream;
import java.io.InterruptedIOException;

public class InterruptableInputStream extends InputStream {
    private final InputStream in;

    public InterruptableInputStream(InputStream in) {
        this.in = in;
    }

    @Override
    public int read() throws IOException {
        while (true) {
            if (in.available() > 0) {
                return in.read();
            }
            if (Thread.interrupted()) {
                throw new InterruptedIOException();
            }
            Thread.yield();
        }
    }

    @Override
    public void close() throws IOException {
        in.close();
    }
}

@@ -216,16 +216,50 @@
 ream in;
+%0A    private final long sleepTime;
 %0A%0A    pu
@@ -322,16 +322,151 @@
 this
-.in = in
+(in, -1);%0A    %7D%0A%0A    public InterruptableInputStream(InputStream in, long sleepTime) %7B%0A        this.in = in;%0A        this.sleepTime = sleepTime
 ;%0A  
@@ -758,23 +758,287 @@
     
-Thread.yield();
+if (sleepTime %3C 0) %7B%0A                Thread.yield();%0A            %7D else %7B%0A                try %7B%0A                    Thread.sleep(sleepTime);%0A                %7D catch (InterruptedException e) %7B%0A                    throw new InterruptedIOException();%0A                %7D%0A            %7D
 %0A   

Add a way to make InterruptableInputStream sleep instead of yielding.