title: Is AtomicInteger a good solution to provide a counter for multithreaded app?
body: <p>I have an android client which will make Http connections to a server.</p>
  
  <p>The server requires that all Http request provide a monotonically increasing counter in the Http header. e.g.</p>
  
  <pre><code>POST /foo/server
  X-count: 43
  </code></pre>
  
  <p>Places that will initiate Http connections:</p>
  
  <ol>
  <li>Inside activities under the user's command e.g. button clicks</li>
  <li>Inside a Service (started by <code>Context#startService</code>)</li>
  </ol>
  
  <p>To dish out counter values, I plan to host an <code>AtomicInteger</code> in my <code>Application</code> subclass. All code will then retrieve a count from a central place. </p>
  
  <p>If the Http connection fails (e.g. server is down), I need to decrement the counter.</p>
  
  <p>Do you think AtomicInteger is a good fit for my scenario ?</p>