title: Is an IntentService's onStartCommand(..) method thread safe?
body: <p>I have an <a href="http://developer.android.com/reference/android/app/IntentService.html">IntentService</a> class that can be started from various places in a complex application - Activities, background Threads, other Services. I'd like to keep a counter of how many times the service was invoked. I use a private int variable within my IntentService class to keep track of that, I increment it from my <a href="http://developer.android.com/reference/android/app/IntentService.html#onStartCommand%28android.content.Intent,%20int,%20int%29">onStartCommand(...)</a> method.</p>
  
  <p>It just occured to me, as the onStartCommand(...) method can be called from various asynchronous threads, that this might not be a thread-safe solution. So the question is, do I need to wrap the access to this counter variable in a synchronized block, or does the IntentService implementation of onStartCommand(...) takes care of this for me?</p>
  
  <p>As a note, I know I could safely increment the variable from <a href="http://developer.android.com/reference/android/app/IntentService.html#onHandleIntent%28android.content.Intent%29">onHandleIntent(...)</a>, but I'd need a count on the actual requests and not on the executed intents.</p>