public static void main(String[] args) {
        int minTO = 500;
        int maxTO = 1500;
        int timeoutCnt = 1000;
        int removalCnt = timeoutCnt / 5;
        boolean sleep = false;
        long sleepTime = 50;
        ArrayList<Timeout> timeouts = new ArrayList<>(timeoutCnt);
        Random r = new Random();
        double period_ms;
        long start;

        // Make our timeouts
        for (int i = 0; i < timeoutCnt; i++) {
            int randTO = minTO + r.nextInt(maxTO - minTO + 1);
            timeouts.add(new Timeout(null, null, randTO));
        }

        TimeoutWorker w = new TimeoutWorker();
        new Thread(w).start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ie) {
        }

        start = System.nanoTime();
        for (int i = 0; i < timeoutCnt; i++) {
            w.insert(timeouts.get(i));
            if (sleep) {
                try {
                    Thread.sleep(sleepTime);
                } catch (InterruptedException ie) {
                }
            }
        }
        period_ms = (System.nanoTime() - start) / 1000000d;
        System.out.println("Added " + timeoutCnt + " timeouts in " + period_ms + "ms");

        /* Randomize the removals */
        Collections.shuffle(timeouts, r);
        start = System.nanoTime();
        for (int i = 0; i < removalCnt; i++) {
            if(!timeouts.get(i).hasExpired()){
                // timeout.expire() was NOT called;
                w.cancel(timeouts.get(i));
            }
            //if (sleep) {
            //    try {
            //        Thread.sleep(sleepTime);
            //    } catch (InterruptedException ie) {
            //   }
            //}
        }
        period_ms = (System.nanoTime() - start) / 1000000d;
        System.out.println("Removed " + removalCnt + " timeouts in " + period_ms + "ms");

        // and shutdown
        try {
            Thread.sleep(3000);
        } catch (InterruptedException ie) {
        }
        w.setRunning(false);
    }