title: Long primitive or AtomicLong for a counter?
body: <p>I have a need for a counter of type <code>long</code> with the following requirements/facts:</p>
  
  <ul>
  <li>Incrementing the counter should take as little time as possible.</li>
  <li>The counter will only be written to by one thread.</li>
  <li>Reading from the counter will be done in another thread.</li>
  <li>The counter will be incremented regularly (as much as a few thousand times per second), but will only be read once every five seconds.</li>
  <li>Precise accuracy isn't essential, only a rough idea of the size of the counter is good enough.</li>
  <li>The counter is never cleared, decremented.</li>
  </ul>
  
  <p>Based upon these requirements, how would you choose to implement your counter? As a simple <code>long</code>, as a <code>volatile long</code> or using an <code>AtomicLong</code>? Why?</p>
  
  <p>At the moment I have a <code>volatile long</code> but was wondering whether another approach would be better. I am also incrementing my long by doing <code>++counter</code> as opposed to <code>counter++</code>. Is this really any more efficient (as I have been led to believe elsewhere) because there is no assignment being done?</p>