のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

An error occured while executing doInBackground()

  303     /**
    304      * Creates a new asynchronous task. This constructor must be invoked on the UI thread.
    305      */
    306     public AsyncTask() {
    307         mWorker = new WorkerRunnable<Params, Result>() {
    308             public Result call() throws Exception {
    309                 mTaskInvoked.set(true);
    310 
    311                 Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
    312                 //noinspection unchecked
    313                 return postResult(doInBackground(mParams));
    314             }
    315         };
    316 
    317         mFuture = new FutureTask<Result>(mWorker) {
    318             @Override
    319             protected void done() {
    320                 try {
    321                     postResultIfNotInvoked(get());
    322                 } catch (InterruptedException e) {
    323                     android.util.Log.w(LOG_TAG, e);
    324                 } catch (ExecutionException e) {
    325                     throw new RuntimeException("An error occured while executing doInBackground()",
    326                             e.getCause());
    327                 } catch (CancellationException e) {
    328                     postResultIfNotInvoked(null);
    329                 }
    330             }
    331         };
    332     }
    331     /**
    332      * Removes and signals all waiting threads, invokes done(), and
    333      * nulls out callable.
    334      */
    335     private void finishCompletion() {
    336         // assert state > COMPLETING;
    337         for (WaitNode q; (q = waiters) != null;) {
    338             if (UNSAFE.compareAndSwapObject(this, waitersOffset, q, null)) {
    339                 for (;;) {
    340                     Thread t = q.thread;
    341                     if (t != null) {
    342                         q.thread = null;
    343                         LockSupport.unpark(t);
    344                     }
    345                     WaitNode next = q.next;
    346                     if (next == null)
    347                         break;
    348                     q.next = null; // unlink to help gc
    349                     q = next;
    350                 }
    351                 break;
    352             }
    353         }
    354 
    355         done();
    356 
    357         callable = null;        // to reduce footprint
    358     }