Skip to content

Commit f13a9ee

Browse files
committed
Add some meaningful words to explain the RxJava
1 parent 3dfb755 commit f13a9ee

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,38 @@ The most simply explain one in my mind is
2828
我们可以把Schedulers看作线程控制符,一共五种线程控制符,可以通过这些线程控制符切换不同的线程。以下是五种线程控制符的区别:
2929

3030
To define the "time" of something happen, we need a "Scheduler",
31-
To define the "things happen" of something happe, we need a "Thread"
31+
32+
To define the "things happen" of something happen, we need a "Thread"
3233

3334
1. `Schedulers.immediate()` 在当前线程运行,相当于不切换线程。这是默认的 Scheduler。
3435

36+
**Explain:** Read as "Do it Right now"
37+
3538
2. `Schedulers.newThread()`总是启用新线程,并在新线程执行操作。
39+
40+
**Explain:** Read as "I dont care u are busy or not,Do this too "
41+
3642
3. `Schedulers.io()` I/O 操作(读写文件、数据库、网络信息交互等)所使用的 Scheduler。行为模式和 newThread() 差不多,区别在于 io() 的内部实现是是用一个无数量上限的线程池,可以重用空闲的线程,因此多数情况下 io() 比 newThread() 更有效率。不要把计算工作放在 io() 中,可以避免创建不必要的线程。
43+
44+
**Explain:** Read as "Give me a minutes, I am writing the database "
45+
3746
4. `Schedulers.computation()` 计算所使用的 Scheduler。这个计算指的是 CPU 密集型计算,即不会被 I/O 等操作限制性能的操作,例如图形的计算。这个 Scheduler 使用的固定的线程池,大小为 CPU 核数。不要把 I/O 操作放在 computation() 中,否则 I/O 操作的等待时间会浪费 CPU。
47+
48+
**Explain:** Read as "Give me a minutes, my brain is busy "
49+
3850
5. `AndroidSchedulers.mainThread()` 切换到主线程,指定的操作将在Android 主线程运行。
51+
52+
**Explain:** Read as "Dont do anything else, Just do this one first "
3953

4054
` 其实我们常用的就2种:Schedulers.io()和AndroidSchedulers.mainThread()`
4155

56+
**Note:** Schedulers.io() and AndroidSchedulers.mainThread() are the most common one
57+
4258
> 以下几个例子都是使用Observable.just(1,2,3)创建被观察对象,观察者输出1,2,3.
4359
60+
> This example show how to use make a few threads that we can watch their actions
61+
62+
4463
####1. 基本使用
4564
<img src="screenshots/just.png" width="61%" />
4665
<img src="screenshots/just.gif" width="34%" />

0 commit comments

Comments
 (0)