/** * Alternative to Thread.sleep(). This call defaults to the native version or uses a method that * makes sense for the running thread pool. * * <p>You have to use this instead of Thread.sleep() or you will block the * TestablePriorityScheduler. * * @param sleepTime Time to pause thread * @throws InterruptedException */ protected void sleep(long sleepTime) throws InterruptedException { if (factory == null) { Thread.sleep(sleepTime); } else { factory.makeLock().sleep(sleepTime); } }
/** * Returns a virtual lock for the runnable that makes sense for the processing thread pool. * * @return {@link VirtualLock} to synchronize on and use with pleasure */ protected VirtualLock makeLock() { if (factory == null) { return new NativeLock(); } else { return factory.makeLock(); } }