title: Does an Android Loader perform its work in a separate thread?
body: <p>I am currently implementing my own <code>Loader</code> in Android, since I am using a library for loading stuff, that exposes its API only through callbacks and I still want to use the benefits of loaders. </p>
  
  <p>The library I want to use can take care of running asynchroneously itself or I can force it to  run synchroneously and do the threading myself. The Android documentation tells me the following:</p>
  
  <blockquote>
    <p>Introduced in Android 3.0, loaders make it easy to asynchronously load
    data in an activity or fragment. Loaders have these characteristics:</p>
    
    <p>...</p>
    
    <ul>
    <li>They provide asynchronous loading of data.</li>
    </ul>
    
    <p>...</p>
  </blockquote>
  
  <p>This I interpret as if a <code>Loader</code> always runs in its own Thread and performs the tasks asynchroneously. However, if I then tell the library I want to perform its requests synchroneously, I get the following exception:</p>
  
  <pre><code>AsyncHttpRequest: Unhandled exception origin cause
      android.os.NetworkOnMainThreadException
              at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145)
  </code></pre>
  
  <p>So it seems as if the work I perform in my <code>Loader</code> runs on the Main thread after all, which surprises me. The code looks as follows:</p>
  
  <pre><code>public abstract class AsyncHTTPLoader&lt;E&gt; extends Loader&lt;E&gt; {
      private Network2 mNetwork;
      private String mRequestUrl;
  
      private AsyncHttpResponseHandler mHandler = new AsyncHttpResponseHandler() {
          @Override
          public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
              AsyncHTTPLoader.this.processResponse(new String(responseBody));
          }
      };
  
      public AsyncHTTPLoader(Context context, String url) {
          super(context);
  
          mRequestUrl = url;
          mNetwork = new Network2(getContext());
      }
  
      protected void processResponse(String response) {
          E result = parseResponse(response);
          deliverResult(result);
      }
  
      @Override
      protected void onForceLoad() {
          super.onForceLoad();
          Utils.log(mRequestUrl);
          mNetwork.get(mRequestUrl, mHandler);
      }
  
      public abstract E parseResponse(String response);
  }
  </code></pre>
  
  <p>Do I need to take care of the threading in the loader myself or not? If I go with the Async feature of the library I use, does the <code>processResponse()</code> function block the UI Thread of my app?</p>