Note that there are some explanatory texts on larger screens.

plurals
  1. POExcecuting two Async Tasks parallely at the same time ( Do i really need this?)
    primarykey
    data
    text
    <p>I read probably every tutorial and every forum discussion on that subject but still can't make it happen! and it is very frustrating.<br> it seems that the way to do it is to use executeOnExecutor() method with - AsyncTask.THREAD_POOL_EXECUTOR, and so i did in my code. but still,the second task only beeing executed only after the first one has finished and not in the same time.<br> My min sdk version is 2.3 and the maximum is 4.2, so i did the check:</p> <pre><code>if (android.os.Build.VERSION.SDK_INT &gt;=android.os.Build.VERSION_CODES.HONEYCOMB) { engine.setEnginesTurn(true); engineThread = new EngineThread(board,engine,activity,boardView); rt = new RotateTask(boardView); engineThread.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); rt.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else{ engine.setEnginesTurn(true); engineThread = new EngineThread(board,engine,activity,boardView); rt = new RotateTask(boardView); engineThread.execute(); rt.execute(); } </code></pre> <p>Ignore the boolean variable here..it is not relevant,and also the other code since you wondered why i didn't post it. it is a mess but all working just fine,execpt for the execution of the two tasks. what am i doing wrong?<br> The reason i want the two tasks running parallely is: the first tasks is a computation task and the other one is a custom Hourglass image rotating animation while the computer is thinking (Its a game app). </p> <p>EDIT: Ah.. and just wanted to include that i don't do the animation on the main UI thread is because i use sleep() for the animation ,so can't freeze the main thread.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload