反應式編程起⼿手式-多執⾏行行緒的逆襲
Android Developer - PicCollage
Prada
Why we need Thread?
https://en.wikipedia.org/wiki/Thread_(computing)
UI Heavy World
If you do it wrong.
System will kill you
Requirements of
Background Task
https://www.youtube.com/watch?v=IrKoBFLwTN0
Threading Problems
report the upload progress to UI
Threading Problems
Threads has dependency relationship
Threading Problems
Map-Reduce
Solution from Google -
AsyncTask
Solution from Google -
Handler/Looper
Solution from Java
import java.util.concurrent.*
https://www.goodreads.com/book/show/127932.Java_Concurrency_in_Practice
BlockingQueue
Future<T>
Callable<T>
ThreadPoolExecutor
ConcurrentHashMap<K,V>
CountDownLatch
Solutions from Google
Deferred-Promise Pattern
Bolts-Framework / jDeferred
https://github.com/jdeferred/jdeferred
https://github.com/BoltsFramework
We want more!
https://youtu.be/XLH2v9deew0?t=4m51s
Asynchronous Ideas
1. Explicit execution
2. Easy thread management
3. Easily transformable
4. As few side effect as possible
5. Cancelation
6. Traffic Control
Explicit Execution
Handler RxJava
Easy Thread Management
AsyncTask
How many background threads for uploading photos?
RxJava
Easily transformable
AsyncTask RxJava
As few side effect as possible
<- local storage operation
<- networking operation
As few side effect as possible
AsyncTask RxJava
Cancelation
https://developer.android.com/reference/android/os/AsyncTask.html#cancel(boolean)
Thread
AsyncTask
Cancelation
Traffic Control
Normal Case
Traffic Control
Worst Case
Traffic Control
How to implement it in Java with Threads?
https://www.geeksforgeeks.org/producer-consumer-solution-using-threads-java/
Traffic Control in RxJava2
Take away
RxJava
Android Framework
Code
Complexity
RxJava
Android Framework
Learning
Curve
if your problem is already complicated
Thanks, Question?
Reference
Intro to RxJava/ Christina Lee
https://www.youtube.com/watch?v=XLH2v9deew0
https://medium.com/@pradabear/deferred-promise-e957bcd235a2
Threading Problems
PicCollage High Resolution Capturing
TODO PicCollage Capturing Video

20180524 Android Taipei : RxJava Threading