/** * Fork or not depending on the timeout value. */ boolean forkTimeoutingTask(StatementRunner r, int timeout, List<Throwable> errors) throws InterruptedException { if (timeout == 0) { r.run(); } else { Thread t = new Thread(r, Thread.currentThread().getName() + "-worker"); RandomizedContext.cloneFor(t); t.start(); join(t, timeout); } final boolean timedOut = !r.completed; if (r.error != null) errors.add(r.error); return timedOut; }
/** * Fork or not depending on the timeout value. */ boolean forkTimeoutingTask(StatementRunner r, int timeout, List<Throwable> errors) throws InterruptedException { if (timeout == 0) { r.run(); } else { Thread t = new Thread(r, Thread.currentThread().getName() + "-worker"); RandomizedContext.cloneFor(t); t.start(); join(t, timeout); } final boolean timedOut = !r.completed; if (r.error != null) errors.add(r.error); return timedOut; }