Looking for good example of using get() with an AsyncTask in android

前端 未结 2 455
猫巷女王i
猫巷女王i 2021-01-02 01:09

I\'m curious about the get(long, java.util.concurrent.TimeUnit) function in AsyncTask, but I\'m having a hard time locating an example of it\'s usage.

2条回答
  •  暖寄归人
    2021-01-02 01:42

    Another use of AsyncTask is to know when several AsyncTasks have processed:

    AsyncTask1 a1 = new AsyncTask();
    AsyncTask1 a2 = new AsyncTask();
    
    a1.execute();
    a2.execute();
    
    a1.get();
    a2.get();
    
    Log.d("Example", "a1 and a2 have both finished, you can now proceed");
    

提交回复
热议问题