ArrayList concurrent use of add and remove
807588May 12 2009 — edited May 16 2009Hi
I am using an ArrayList to collect monitoring information for a web service. Each time the web service is called the time that it took to process is added to the ArrayList. The web service calls can be concurrent. Every 5 minutes the ArrayList is cleared (via clear()). I know that any structural changes to an ArrayList should be synchronized, but we are concerned about the performance implications. Also we do not require 100% accurate monitoring stats, but rather an indication (stats are retrieved via JMX). If we do not synchronize the add() and clear() operations is there a possibility of exceptions occurring under heavy load? If no exceptions occur, to what extend would the collected results be inaccurate?
Thanks