How to get synchronized version of ArrayList object?

By default ArrayList object is non synchronized but we can get synchronized version of ArrayList by using collection class’s synchronizedList() method.

Non-synchronized 

ArrayList nonSyncronizedList = new ArrayList();

Synchronized

List syncronizeList = new Collections.synchronizedList(l1);

Similarly we can get synchronized version of set, map objects by using the following methods of collection class.

Public static Set synchronizedSet(Set s);

Public static Map synchronizedMap(Map m);

315 total views, 1 views today