public static LongStream interval(final long delay, final long interval, final TimeUnit unit) {
        return of(new LongIteratorEx() {
            private final long intervalInMillis = unit.toMillis(interval);
            private long nextTime = System.currentTimeMillis() + unit.toMillis(delay);
            private long val = 0;

            @Override
            public boolean hasNext() {
                return true;
            }

            @Override
            public long nextLong() {
                long now = System.currentTimeMillis();

                if (now < nextTime) {
                    N.sleep(nextTime - now);
                }

                nextTime += intervalInMillis;

                return val++;
            }
        });
    }
public static LongStream interval ( final long delay , final long interval , final TimeUnit unit ) { return of ( new LongIteratorEx ( ) { private final long intervalInMillis = unit . toMillis ( interval ) ; private long nextTime = System . currentTimeMillis ( ) + unit . toMillis ( delay ) ; private long val = 0 ; @ Override public boolean hasNext ( ) { return true ; } @ Override public long nextLong ( ) { long now = System . currentTimeMillis ( ) ; if ( now < nextTime ) { N . sleep ( nextTime - now ) ; } nextTime += intervalInMillis ; return val ++ ; } } ) ; }
Generates the long value by the specified period: [0, 1, 2, 3...]

@param delay
@param interval
@param unit
@return