package rxjava;

import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;

import io.reactivex.BackpressureStrategy;
import io.reactivex.Flowable;
import io.reactivex.FlowableEmitter;
import io.reactivex.FlowableOnSubscribe;

/**
 * 
 * @author 张大川
 *
 */
public class HelloWorld {
	public static void main(String[] args) {
		Flowable<String> flowable = Flowable.create(new FlowableOnSubscribe<String>() {

			@Override
			public void subscribe(FlowableEmitter<String> e) throws Exception {
				e.onNext("xxx");
				e.onNext("hello RxJava 2");
				e.onComplete();
			}
		}, BackpressureStrategy.BUFFER);
		Subscriber<String> subscriber = new Subscriber<String>() {
			@Override
			public void onSubscribe(Subscription s) {
				System.out.println("onSubscribe");
				s.request(Long.MAX_VALUE);
			}

			@Override
			public void onNext(String s) {
				try {
					Thread.sleep(10000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				System.out.println(s);
			}

			@Override
			public void onError(Throwable t) {

			}

			@Override
			public void onComplete() {
				System.out.println("onCompxxx");
			}

		};

		flowable.subscribe(subscriber);
	}
}

@@ -267,16 +267,22 @@
 r %E5%BC%A0%E5%A4%A7%E5%B7%9D%0A *
+ %E7%AC%AC%E4%B8%80%E4%B8%AA%E7%A4%BA%E4%BE%8B
 %0A */%0Apub

Update HelloWorld.java