// If all streams are nil, just sleep the specified time (JRUBY-4699)
if (args[0].isNil() && args[1].isNil() && args[2].isNil()) {
if (timeout > 0) {
RubyThread thread = context.getThread();
long now = System.currentTimeMillis();
thread.sleep(timeout);
// Guard against spurious wakeup
while (System.currentTimeMillis() < now + timeout) {
thread.sleep(1);
}