An analysis of the asynctask mechanism of Android Learning notes

Source: Internet
Author: User
<span id="Label3"></p>I. Related BASIC 1 uses <blockquote> <blockquote> <p>Used to quickly open asynchronous tasks and handle time-consuming operations. Processes asynchronous tasks in a thread pool, and submits progress and processing results to the main thread processing.</p> </blockquote> </blockquote>2 asynctask generic parameter-params, Progress, Result <blockquote> <blockquote> <p>Params indicates the type of the passed-in doinbackground parameter<br>Progress indicates the type of background task execution progress<br>Result indicates the type of the result returned after the background task execution completes</p> </blockquote> </blockquote><pre><pre><code>若不需要传入具体的参数,传入Void即可</code></pre></pre>3 Common methods <blockquote> <blockquote> <p>OnPreExecute before the UI thread executes the task, before Doinbackground executes<br>Doinbackground performing background tasks, child threads, can call publishprogress to publish updates on the UI thread<br>Onprogressupdate Progress update, UI thread<br>When the OnPostExecute task finishes, the UI thread<br>When the oncancelled task is canceled and OnPostExecute does not execute, the UI thread</p> </blockquote> </blockquote>4 several important nouns <blockquote> <blockquote> <p>Internalhandler asynctask Internal handler, handling tasks for submitting and updating messages<br>Serialexecutor serial thread pool for Task scheduling, task queuing, only one task at a time<br>Thread_pool_executor thread pool, for real task execution<br>Workerrunnable implements the callable interface for background computing</p> </blockquote> </blockquote>5 Approximate process <blockquote> <blockquote> <p>1. onpreexecute, before executing the task, runs on the UI thread before Doinbackground executes</p> <p>2, result = Doinbackground (), perform background task, return execution result, execute in thread pool, cooperate with publishprogress to update task progress</p> <p>3, onprogressupdate, Call the Publishprogress method in the Doinbackground method, for Progress update, run on UI thread (switch to main thread via internal Handler)</p> <p>4, onpostexecute, run on UI thread, process run result (switch to main thread via internal Handler)</p> </blockquote> </blockquote>second, the implementation Process Analysis 1. The Asynctask object is constructed first, which must be called on the main thread<pre><code>/** * Creates a new asynchronous Task. This constructor must is invoked on the UI Thread. */public asynctask () {//instantiation workerrunnable Object mworker = new workerrunnable<params, result> () {public Result Call () throws Exception {mtaskinvoked.set (true); Process.setthreadpriority (process.thread_priority_background); Noinspection unchecked return Postresult (doinbackground (mparams)); }};//instantiation futuretask mfuture = new futuretask<result> (mworker) {@Override protected void done () {try {postresultifnotinvoked (get ()); } catch (interruptedexception E) {android.util.log.w (log_tag, e); } catch (executionexception e) {throw new runtimeexception ("an error occured while executing Doinbackgroun D () ", E.getcause ()); } catch (cancellationexception E) {postresultifnotinvoked (null); } } };} </code></pre><p><p>Mworker is the workerrunnable object, which is an abstract class and implements the callable interface for computing a task</p></p><pre><pre><code> private static abstract class WorkerRunnable<Params, Result> implements Callable<Result> { Params[] mParams;}</code></pre></pre><p><p>Mfuture is the Futuretask object, the following constructs are used,</p></p><pre><pre><code> public FutureTask(Callable<V> callable) { if (callable == null) throw new NullPointerException(); this.callable = callable; this.state = NEW; // ensure visibility of callable}</code></pre></pre>2. Perform a task starting with its Execute method <blockquote> <blockquote> <p>The Execute method is as follows, it calls the Executeonexecutor method, and you can see that sdefaultexecutor is used by default, which is Serialexecutor</p> </blockquote> </blockquote><pre><pre><code> public final AsyncTask<Params, Progress, Result> execute(Params... params) { return executeOnExecutor(sDefaultExecutor, params);}</code></pre></pre> <blockquote> <blockquote> <p>Executeonexecutor method, This method first checks the running state and assigns a new state, then callbacks the OnPreExecute method, assigns Mworker parameters, and finally lets executor perform the task and returns the Asynctask Object.</p> </blockquote> </blockquote><pre><pre><code>public final AsyncTask<Params, Progress, Result> executeOnExecutor(Executor exec, Params... params) { if (mStatus != Status.PENDING) { switch (mStatus) { case RUNNING: throw new IllegalStateException("Cannot execute task:" + " the task is already running."); case FINISHED: throw new IllegalStateException("Cannot execute task:" + " the task has already been executed " + "(a task can be executed only once)"); } } mStatus = Status.RUNNING; onPreExecute(); // 在主线程中回调 mWorker.mParams = params; exec.execute(mFuture); // 传参FutureTask对象 return this;}</code></pre></pre> <blockquote> The <blockquote> <p> Exec is the executor object, which is used by default with the Serialexecutor (serial thread Pool) to dispatch task queuing order Execution. Task scheduling is enabled through Exec.execute (mfuture), and other tasks wait while there is a task executing. Mtasks is arraydeque, which is a double-ended Queue. When adding a task for the first time, Mtasks.offer adds the new task to the end of the task queue, at which point the mactive runnable is empty, so it will go straight to determine if the Schedulenext method is airborne, and in this method through Thread_pool_ Executor.execute (mactive) opens the execution task. The successor task will go to the schedulenext in the finally, and mactive is not empty at this Time. When the R.run () method is executed, the Run method of the Futuretask object is called </p> </blockquote> </blockquote><pre><pre><code> private static class SerialExecutor implements Executor { final ArrayDeque<Runnable> mTasks = new ArrayDeque<Runnable>(); Runnable mActive; public synchronized void execute(final Runnable r) { mTasks.offer(new Runnable() { public void run() { try { r.run(); } finally { scheduleNext(); } } }); if (mActive == null) { scheduleNext(); } } protected synchronized void scheduleNext() { if ((mActive = mTasks.poll()) != null) { THREAD_POOL_EXECUTOR.execute(mActive); }}</code></pre></pre> <blockquote> <blockquote> <p>The Run method of the Futuretask object is as follows, the callable object is the Mworker,c.call () that is passed in when the Futuretask object is constructed, and the call method that calls Mworker in the run method, and the result is saved at Result. The call method runs on a child thread</p> </blockquote> </blockquote><pre><code><code> public void Run () {if (state! = NEW | | ! Unsafe.compareandswapobject (this, runneroffset, null, thread.currentthread ())) Return Try {callable<v> C = callable; The callable object is the mworker if (c! = null && state = = NEW) that is passed in when constructing the Futuretask object {V result; Boolean ran; Try {result = C.call (); ran = true; } catch (throwable Ex) {result = null; ran = false; SetException (ex); } If (ran) set (result); }} finally {//runner must be non-null until the state was settled to//prevent concurrent calls to run () Runner = null; State must is re-read after nulling runner to prevent//leaked interrupts int s = state; If (s >= Interrupting) handlepossiblecancellationinterrupt (s); }}</code></code></pre> <blockquote> <blockquote> <p>The call method for the Workerrunnable object is as follows, it calls the Doinbackground method and passes its return value as a parameter to the Postresult method. To this call the Doinbackground method, which runs in the thread pool</p> </blockquote> </blockquote><pre><pre><code>public Result call() throws Exception { mTaskInvoked.set(true); Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); //noinspection unchecked return postResult(doInBackground(mParams)); }</code></pre></pre> <blockquote> <blockquote> <p>The Postresult method, which sends task completion information to asynctask internal Internalhandler</p> </blockquote> </blockquote><pre><pre><code>private Result postResult(Result result) { @SuppressWarnings("unchecked") Message message = sHandler.obtainMessage(MESSAGE_POST_RESULT, new AsyncTaskResult<Result>(this, result)); message.sendToTarget(); return result;}</code></pre></pre>3. Internalhandler Message Processing <blockquote> <blockquote> <p>Internalhandler is as follows, when the message type is message_post_result, the completion method is used to complete the execution of the result Submission. When the message type is message_post_progress, the callback updates the progress Onprogressupdate method. Switch to main thread via internal handler</p> </blockquote> </blockquote><pre><pre><code>private static class InternalHandler extends Handler { @SuppressWarnings({"unchecked", "RawUseOfParameterizedType"}) @Override public void handleMessage(Message msg) { AsyncTaskResult result = (AsyncTaskResult) msg.obj; switch (msg.what) { case MESSAGE_POST_RESULT: // There is only one result result.mTask.finish(result.mData[0]); break; case MESSAGE_POST_PROGRESS: result.mTask.onProgressUpdate(result.mData); break; } }}</code></pre></pre> <blockquote> <blockquote> <p>The Finish method is as follows, call OnPostExecute when the task is not canceled, or call Oncancelled. Are running in the main thread</p> </blockquote> </blockquote><pre><pre><code>private void finish(Result result) { if (isCancelled()) { onCancelled(result); } else { onPostExecute(result); } mStatus = Status.FINISHED;}</code></pre></pre>4. Progress Updates <blockquote> <blockquote> <p>publishprogress, called in the Doinbackground method, to update the PROGRESS. This method sends a MESSAGE_POST_PROGRESS message to Internalhandler to update the progress on the UI thread</p> </blockquote> </blockquote><pre><pre><code>/** * This method can be invoked from {@link #doInBackground} to * publish updates on the UI thread while the background computation is * still running. Each call to this method will trigger the execution of * {@link #onProgressUpdate} on the UI thread. * * {@link #onProgressUpdate} will note be called if the task has been * canceled. * * @param values The progress values to update the UI with. * * @see #onProgressUpdate * @see #doInBackground */protected final void publishProgress(Progress... values) { if (!isCancelled()) { sHandler.obtainMessage(MESSAGE_POST_PROGRESS, new AsyncTaskResult<Progress>(this, values)).sendToTarget(); }}</code></pre></pre>Simple case<p><p>The case is a simple simulation of the sum operation and a view of the threads that each method runs<br>Customizing asynchronous Task Class inheritance in Mainactivity asynctask</p></p><pre class="prettyprint"><code class=" hljs axapta"><span class="hljs-class"><span class="hljs-class"> <span class="hljs-keyword">class</span> <span class="hljs-title">backtask</span> <span class="hljs-inheritance"><span class="hljs-keyword">extends</span></span> <span class="hljs-title">asynctask</span><<span class="hljs-title">integer</span>, <span class="hljs-title">integer</span>, <span class="hljs-title">Integer</span>> {</span></span>@Override<span class="hljs-keyword"><span class="hljs-keyword">protected</span></span> <span class="hljs-keyword"><span class="hljs-keyword">void</span></span>OnPreExecute () {LOG.E (<span class="hljs-string"><span class="hljs-string">"TAG"</span></span>,<span class="hljs-string"><span class="hljs-string">"before The Onpreexecute-task executes, the current thread:"</span></span>+thread.currentthread (). GetName ());<span class="hljs-keyword"><span class="hljs-keyword">Super</span></span>. OnPreExecute (); } @Override<span class="hljs-keyword"><span class="hljs-keyword">protected</span></span>Integer doinbackground (integer ... params) {log.e (<span class="hljs-string"><span class="hljs-string">"TAG"</span></span>,<span class="hljs-string"><span class="hljs-string">"doinbackground-task Execution ..., current thread:"</span></span>+thread.currentthread (). GetName ());<span class="hljs-keyword"><span class="hljs-keyword">int</span></span>N = params[<span class="hljs-number"><span class="hljs-number">0</span></span>];<span class="hljs-keyword"><span class="hljs-keyword">int</span></span> <span class="hljs-keyword"><span class="hljs-keyword">Count</span></span>=<span class="hljs-number"><span class="hljs-number">0</span></span>;<span class="hljs-keyword"><span class="hljs-keyword">int</span></span>Total =<span class="hljs-number"><span class="hljs-number">0</span></span>;<span class="hljs-comment"><span class="hljs-comment">//calculate sum</span></span>Integer progress =<span class="hljs-number"><span class="hljs-number">0</span></span>;<span class="hljs-comment"><span class="hljs-comment">//progress</span></span> <span class="hljs-keyword"><span class="hljs-keyword"></span> while</span>(<span class="hljs-keyword"><span class="hljs-keyword">Count</span></span>< N) {+ +<span class="hljs-keyword"><span class="hljs-keyword">Count</span></span>; Total + =<span class="hljs-keyword"><span class="hljs-keyword">Count</span></span>; Progress =<span class="hljs-keyword"><span class="hljs-keyword">Count</span></span>*<span class="hljs-number"><span class="hljs-number"></span> -</span>N Publishprogress (progress); }<span class="hljs-keyword"><span class="hljs-keyword">return</span></span>Total } @Override<span class="hljs-keyword"><span class="hljs-keyword">protected</span></span> <span class="hljs-keyword"><span class="hljs-keyword">void</span></span>OnPostExecute (Integer Result) {<span class="hljs-keyword"><span class="hljs-keyword">Super</span></span>. OnPostExecute (result); LOG.E (<span class="hljs-string"><span class="hljs-string">"TAG"</span></span>,<span class="hljs-string"><span class="hljs-string">"onpostexecute-executes The result, the sum of the operations is"</span></span>+ result+<span class="hljs-string"><span class="hljs-string">", Current thread:"</span></span>+thread.currentthread (). GetName ()); } @Override<span class="hljs-keyword"><span class="hljs-keyword">protected</span></span> <span class="hljs-keyword"><span class="hljs-keyword">void</span></span>Onprogressupdate (Integer ... values) {<span class="hljs-keyword"><span class="hljs-keyword">Super</span></span>. onprogressupdate (values); LOG.E (<span class="hljs-string"><span class="hljs-string">"TAG"</span></span>,<span class="hljs-string"><span class="hljs-string">"onprogressupdate-current progress:"</span></span>+ values[<span class="hljs-number"><span class="hljs-number">0</span></span>] +<span class="hljs-string"><span class="hljs-string">"%"</span></span>+<span class="hljs-string"><span class="hljs-string">", Current thread:"</span></span>+thread.currentthread (). GetName ()); } }</code></pre><p><p>To open a task in the OnCreate method</p></p><pre class="prettyprint"><pre class="prettyprint"><code class=" hljs vbscript"><span class="hljs-keyword">new</span> BackTask().<span class="hljs-keyword">execute</span>(<span class="hljs-number">100</span>);</code></pre></pre><p><p>The operation results are as follows</p></p><pre class="prettyprint"><code class=" hljs r"><span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.508</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onpreexecute-the Current thread before the task Executes: main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.508</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): Doinbackground-task Execution<span class="hljs-keyword"><span class="hljs-keyword">...</span></span>, Current thread: Asynctask<span class="hljs-comment"><span class="hljs-comment">#2</span></span><span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.578</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number">1</span></span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.578</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number">2</span></span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.578</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number">3</span></span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.578</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number">4</span></span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.578</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number">5</span></span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.578</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number">6</span></span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.578</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number">7</span></span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.578</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number">8</span></span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.578</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number">9</span></span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.578</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number">Ten</span></span>%, Current Thread: Main<span class="hljs-keyword"><span class="hljs-keyword">...</span></span> <span class="hljs-keyword"><span class="hljs-keyword">...</span></span> <span class="hljs-keyword"><span class="hljs-keyword">...</span></span> <span class="hljs-keyword"><span class="hljs-keyword">...</span></span>(omit Partial Output)<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.608</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number"></span> -</span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.608</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number"></span> the</span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.608</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number"></span> the</span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.608</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number"></span> the</span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.608</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number">94</span></span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.608</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number"></span> the</span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.608</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number"></span> the</span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.608</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number"></span> the</span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.608</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number">98</span></span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.608</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number"></span> about</span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.608</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onprogressupdate-current progress:<span class="hljs-number"><span class="hljs-number"></span> -</span>%, Current Thread: Main<span class="hljs-number"><span class="hljs-number"></span> the</span>-<span class="hljs-number"><span class="hljs-number"></span> -</span> <span class="hljs-number"><span class="hljs-number"></span> ,</span>:<span class="hljs-number"><span class="hljs-number"></span> -</span>:<span class="hljs-number"><span class="hljs-number">53.608</span></span>: E/tag (<span class="hljs-number"><span class="hljs-number">2710</span></span>): onpostexecute-executes The result, the sum of the operations is<span class="hljs-number"><span class="hljs-number">5050</span></span>, current Thread: Main</code></pre> <p><p>An analysis of the asynctask mechanism of Android Learning notes</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.