title: Multiple Services on Multiple Threads Lifecycle
body: <p>These methods are implemented in a class extending Service. A new service is started every time a button is pressed. </p>
  
  <p>If the button is pressed once, LogCat outputs what I expect, which includes a final output of "Service onDestroy." However, when the button is pressed twice, the second time before the first service ended, "Service onDestroy." displays only once when the first service is done, and the second service prints out the rest of "Service Running" logs but not "Service onDestroy."</p>
  
  <p>Can anyone tell me why? Thank you!</p>
  
  <pre><code>public int onStartCommand(Intent intent,int flags, int startId) {
      Log.i(TAG,"Service onStartCommand " + startId);
  
      final int currentId = startId;
  
      Runnable r = new Runnable() {
          public void run() {
              for (int i = 0; i &lt; 3; i++) {
                  long endTime = System.currentTimeMillis() + 10*1000;
                  while (System.currentTimeMillis() &lt; endTime) {
                      synchronized(this) {
                          try {
                              wait(endTime - System.currentTimeMillis());
                          }catch (Exception e) {
  
                          }
                      }
                  }
                  Log.i(TAG,"Service running");
              }
              stopSelf();
          }
      };
  
      Thread t = new Thread(r);
      t.start();
  
  
      return Service.START_STICKY;
  }
  
  
  @Override
  public IBinder onBind(Intent intent) {
      // TODO Auto-generated method stub
      Log.i(TAG,"Service onBind");
  
      return null;
  }
  
  
  
  @Override
  public void onDestroy() {
      Log.i(TAG,"Service onDestroy");
  }
  </code></pre>