title: Why use Service if it runs in the same thread in android
body: <p>I was going through <a href="https://d.android.com/guide/components/bound-services" rel="noreferrer">Bound Service</a> in Android Developer website. I thought I understood the service enough but I just found another way of connecting service through Using a <a href="https://d.android.com/reference/android/os/Messenger" rel="noreferrer"><code>Messenger</code></a> class especially for local service. There I got confused. Maybe I got the concept wrong.</p>
  
  <p>Here is my understanding of Android <a href="https://d.android.com/reference/android/app/Service" rel="noreferrer"><code>Service</code></a>. You create a service when</p>
  
  <ol>
  <li>You want to do separate jobs in the <strong>background</strong>.</li>
  <li>You want to make it a separate process.</li>
  <li>You want to make it run in a lifecycle that's independent of the component that started it. </li>
  </ol>
  
  <p>Confusion is the first item in the list, the definition of the background. Isn't the background a thread or process? I never thought that it can run on the main thread.</p>
  
  <p>Here is the caution of service in the dev pages about.</p>
  
  <blockquote>
    <p><strong>Caution</strong>: A service runs in the main thread of its hosting process—the service does not create its own thread and does not run in a separate process (unless you specify otherwise). This means that, if your service is going to do any CPU intensive work or blocking operations (such as MP3 playback or networking), you should create a new thread within the service to do that work. By using a separate thread, you will reduce the risk of Application Not Responding (ANR) errors and the application's main thread can remain dedicated to user interaction with your activities.</p>
  </blockquote>
  
  <p>Questions</p>
  
  <ol>
  <li>Why does one choose to use service if the service function will anyway run on the main thread? </li>
  <li>Do we have to write a service only to block ANR even if the time-consuming job is done in the main thread? Assume the service is only for my application. </li>
  <li>Are there any practical cases or reasons to use a service as private and running in the same thread?</li>
  </ol>