src/main/java/io/reactivex/Observable.java
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public static <T, S> Observable<T> generate(Callable<S> initialState, BiFunction<S, Emitter<T>, S> generator) {
        return generate(initialState, generator, Functions.emptyConsumer());
    }
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public static <T, S> Observable<T> generate(Callable<S> initialState, BiFunction<S, Emitter<T>, S> generator) {
        return generate(initialState, generator, Functions.emptyConsumer());
    }
Returns a cold, synchronous and stateful generator of values.
<p>
<img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/generate.2.png" alt="">
<p>
Note that the {@link Emitter#onNext}, {@link Emitter#onError} and
{@link Emitter#onComplete} methods provided to the function via the {@link Emitter} instance should be called synchronously,
never concurrently and only while the function body is executing. Calling them from multiple threads
or outside the function call is not supported and leads to an undefined behavior.
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code generate} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>

@param <S> the type of the per-Observer state
@param <T> the generated value type
@param initialState the Callable to generate the initial state for each Observer
@param generator the Function called with the current state whenever a particular downstream Observer has
requested a value. The callback then should call {@code onNext}, {@code onError} or
{@code onComplete} to signal a value or a terminal event and should return a (new) state for
the next invocation. Signalling multiple {@code onNext}
in a call will make the operator signal {@code IllegalStateException}.
@return the new Observable instance