title: JEE6 @ApplicationScoped bean and concurrency
body: <p>I need to write a bean that would act as a counter of how many times it was accessed.</p>
  
  <p>I'm thinking of using <code>@ApplicationScoped</code> bean with <code>AtomicInteger</code> like that</p>
  
  <pre><code>@ApplicationScoped
  class VisitsCounter {
  
      private AtomicInteger counter;
  
      @PostConstruct
      public void construct() {
          counter = new AtomicInteger(0);
      }
  
      public int visited() {
          return counter.incrementAndGet();
      }
  }
  </code></pre>
  
  <p>My question is: is it ok when considering multiple requests at the same time? Or do i need to play with <code>@ConcurrencyManagement</code> and <code>@Lock</code> annotations? I suppose that <code>Atomic*</code> should do the trick but I'm not sure.</p>
  
  <p>Also does the same applies when I have thread safe collections as a fields? E.g. say I have</p>
  
  <pre><code>@ApplicationScoped
  class ValuesHolder {
  
      private List&lt;String&gt; values;
  
      @PostConstruct
      public void construct() {
          values = Collections.synchronizedList(new LinkedList&lt;String&gt;());
      }
  
      public void insert(String value) {
          values.add(value);
      }
  
      public String remove(String value) {
          return values.remove(value);
      }
  }
  </code></pre>
  
  <p>are the operations really thread-safe? </p>
  
  <p>It is said that concurrency annotations and locks should be used when there is modification of state of the bean, but what if my list already takes care of thread safety?</p>