title: Which data structure to use to store millions of objects in multithreading environment ( Scalability and performace )?
body: <p>My requirement is like : I want to perform <strong>frequent</strong> operation on <strong>millions</strong> of objects in multi-threaded environment with <strong>concurrency and scalability</strong> keeping in mind, I need best data structure suitable for this requirement. </p>
  
  <p>For example : </p>
  
  <pre><code>public interface CarDetails {
     public CopyOnWriteArrayList&lt;Car&gt; getAllCars();
     public Car getMostSoldCars(int carModel);
     public void addNewCarDetails(Car car);
     public void oldCardDetails(Car car);
  }     
  </code></pre>
  
  <p>Initially i had thought to use concurrent API's(<strong>CopyOnWriteArrayList</strong>) as its performs better compared to externally synchronizing the List( <strong>eg: Collections.synchronizedList(list object)</strong>).</p>
  
  <p><strong>Issue with CopyOnWriteArrayList :</strong> To store millions of objects in memory and performing frequest operations on it has performance impact because CopyOnWriteArrayList creates entirely new List whenever any updation occurs on it and performing such opertions on millions of objects has performance issue. It is good for multiple readers but i am looking for performance on large number of objects.</p>
  
  <p><strong>Issue with Collections.synchronizedList(list object) :</strong> Externally synchronizing the list has another issue because it locks on entire object which has another performance issue.</p>
  
  <p>Could anyone suggest me , Which collection API's is suitable for this type of requirement( Concurrency , Scalability , Millions of objects , better performance on frequent operation).</p>
  
  <p>Thanks in advance !!!</p>