title: Executing a runnable in Asynctask
body: <p>I have a class <code>AsycnIntegerCounter</code> which extends <code>AsyncTask</code>, with <code>doInBackground()</code> and <code>onPostExecute()</code> overridden in the same.
  From my main thread, I am able to create a runnable object and execute it using the 
  <code>AsycnIntegerCounter</code>'s static execute method.   <code>AsycnIntegerCounter.execute(Runnable)</code></p>
  
  <p>Can anyone help me in understanding what exactly happens when we execute a runnable using <code>AsycnIntegerCounter</code> (i.e) using <code>AsycnTask</code> object. </p>
  
  <p><em><strong>When this can be used ? and what is the advantage rather than running using a Thread object?</em></strong></p>
  
  <p><strong>Code Sample:</strong></p>
  
  <pre><code>AsycnIntegerCounter integerCounter1 = new AsycnIntegerCounter(next,0);
  
  AsycnIntegerCounter.execute(new Runnable() {
  
              @Override
              public void run() {
  
                  int i = 100;
                  while(i&lt;=105){
  
                      i++;
                      try {
                          Thread.sleep(1000);
  
                      } catch (InterruptedException e) {
  
                          e.printStackTrace();
                      }
                  }
              }
          });
  </code></pre>