title: ANR caused by service
body: <p>I have a service that starts a <code>newSingleThreadScheduledExecutor()</code>.
  Therefore, all the job done is done in a worker thread.
  What is done in the thread is, retrieve a value from server, do some easy computation and save a value in SharedPreference.</p>
  
  <p>Rarely, I get ANR, and log mesage tells it's caused by my service.<br>
  Do you have any idea why it can happens ?</p>
  
  <p>Also, in case it matters, i sometime restart my Service (stopping it, which call shutdownNow() on the <code>ScheduledExecutorService</code>, and restarting it).</p>
  
  <p>Here is the relevant part of code.  </p>
  
  <pre><code>public void onCreate() {
          sharedPreferences = getSharedPreferences(Constant.SHARED_PREFERENCE, MODE_PRIVATE);
          broadcaster = LocalBroadcastManager.getInstance(this);
          registerReceiver();
  
          if(scheduler == null) {
              scheduler = Executors.newSingleThreadScheduledExecutor();
              scheduler.scheduleWithFixedDelay
                      (new Runnable() {
                          public void run() {
                              android.util.Log.d(TAG, "globalLogic Scheduler started");
                              globalLogic();
                          }
                      }, 0, CHECK_PERIOD, TimeUnit.HOURS);
          }
      }
  </code></pre>