In Java as we know that Collections are one of most important concept which makes Java as a powerful language in itself. It is only support of collections in Java which make it to support any type of data in a convenient and efficient way along with possible CRUD operations over them.
But on same phase when collections get exposed to the multi-threading its performance get somewhat degraded because of somewhere collections lack the support to multi-threading environment. To overcome this limitation Java introduces Concurrent Collections which not only overcome the multi-threading environment limitation but also enhances the Java to perform with multiple threads data.
Following are the important differences between Traditional Collections and Concurrent Collections.
|Sr.No.||Key||Traditional Collections||Concurrent Collections|
|1||Thread Safety||Most of the classic classes in Java Collections such as Array List, Linked List, Hash Map etc. are not synchronized and are not thread safe in multi-threading environment.||On other hand Java introduces same classes in Concurrent Collections with implement synchronization in them which not only make these classes as Synchronized but also thread safe in nature.|
|2||Locking Mechanism||We have some synchronized classes in traditional collections as well such as Vector and Stack but these classes uses lock over whole collection which reduces performance and speed of execution.||On other hand concurrent collections introduces concept of partial locking where it locks only part of collection in case of multi-threading environment which improves the performance and speed of collections in such environment.|
|3||Runtime Exception||In case of traditional collections if we try to modify a collection through separate thread during collection iteration then we got Runtime Exception ConcurrentModificationException.||On other hand one would not get such exception if deals with the concurrent collections i.e. concurrent collections allows modification in collection during its iteration.|
|4||Preference||Due to reason mentioned in above points traditional collections are not preferred in multi-threading environment.||On other hand Concurrent collections are primarily preferred in multi-threading environment.|
|5||Introduction in market||Traditional collections are type of legacy collection in Java and are introduced before concurrent collections.||While concurrent collections are introduced in JDK 1.5 i.e. are introduced after traditional collections.|