HashedWheelTimer implements Timer { @Override public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { if (task == null) { throw new NullPointerException("task"); } if (unit == null) { throw new NullPointerException("unit"); } long pendingTimeoutsCount = pendingTimeouts.incrementAndGet(); if (maxPendingTimeouts > 0 && pendingTimeoutsCount > maxPendingTimeouts) { pendingTimeouts.decrementAndGet(); throw new RejectedExecutionException("Number of pending timeouts (" + pendingTimeoutsCount + ") is greater than or equal to maximum allowed pending " + "timeouts (" + maxPendingTimeouts + ")"); } start(); long deadline = System.nanoTime() + unit.toNanos(delay) - startTime; if (delay > 0 && deadline < 0) { deadline = Long.MAX_VALUE; } HashedWheelTimeout timeout = new HashedWheelTimeout(this, task, deadline); timeouts.add(timeout); return timeout; } HashedWheelTimer();  HashedWheelTimer(long tickDuration, TimeUnit unit);  HashedWheelTimer(long tickDuration, TimeUnit unit, int ticksPerWheel);  HashedWheelTimer(ThreadFactory threadFactory);  HashedWheelTimer(
            ThreadFactory threadFactory, long tickDuration, TimeUnit unit);  HashedWheelTimer(
            ThreadFactory threadFactory,
            long tickDuration, TimeUnit unit, int ticksPerWheel);  HashedWheelTimer(
            ThreadFactory threadFactory,
            long tickDuration, TimeUnit unit, int ticksPerWheel,
            long maxPendingTimeouts); void start(); @Override Set<Timeout> stop(); @Override boolean isStop(); @Override Timeout newTimeout(TimerTask task, long delay, TimeUnit unit); long pendingTimeouts(); static final String NAME; }
@Test public void newTimeout() throws InterruptedException { final Timer timer = newTimer(); for (int i = 0; i < 10; i++) { timer.newTimeout(new PrintTask(), 1, TimeUnit.SECONDS); Thread.sleep(1000); } Thread.sleep(5000); }