src/main/java/io/reactivex/Observable.java
@CheckReturnValue
    @NonNull
    @SchedulerSupport(SchedulerSupport.NONE)
    public static <T> Observable<T> generate(final Consumer<Emitter<T>> generator) {
        ObjectHelper.requireNonNull(generator, "generator is null");
        return generate(Functions.<Object>nullSupplier(),
        ObservableInternalHelper.simpleGenerator(generator), Functions.<Object>emptyConsumer());
    }
@CheckReturnValue
    @NonNull
    @SchedulerSupport(SchedulerSupport.NONE)
    public static <T> Observable<T> generate(final Consumer<Emitter<T>> generator) {
        ObjectHelper.requireNonNull(generator, "generator is null");
        return generate(Functions.<Object>nullSupplier(),
        ObservableInternalHelper.simpleGenerator(generator), Functions.<Object>emptyConsumer());
    }
Returns a cold, synchronous and stateless 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 <T> the generated value type
@param generator the Consumer called 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. Signalling multiple {@code onNext}
in a call will make the operator signal {@code IllegalStateException}.
@return the new Observable instance