How to execute two methods async in RxJava?

16 Views Asked by At

How to execute two methods async? I have two methods call from menu click, and I need second method execute after first. But I can't understand why result.get() in makeMark() waits Thread.sleep(10000) and getResult ?

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    makeMark(id); 
    try {
       Thread.sleep(10000);
    } catch (InterruptedException e1) {
    }
    getResult() //must execute after makeMark() 
    return true
}


public static void makeMark(id){
     databaseCall(id)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(result -> {
            result.get() //why this execute after thread sleep?
)
0

There are 0 best solutions below