title: Can I rely on the garbage collector to stop an AsyncTask?
body: <p>A quick theoretical question. Suppose I have a Java class which makes use of both a finalizer and an instance of its own private AsyncTask not referenced anywhere else.</p>
  
  <p>Now suppose the AsyncTask's doInBackground method is something like:</p>
  
  <pre><code>while(go) {
   f();
  }
  </code></pre>
  
  <p>and the finalizer is:</p>
  
  <pre><code>public void finalize() {
   go = false;
  }
  </code></pre>
  
  <p>When all external references to the object are deleted, will the AsyncTask be stopped? Or will the system continue with the thread, never deleting the object because it is referenced by the thread? </p>