Untitled Document

Subscribe here to get updates on new Videos


26. How to get Synchronized version of ArrayList ?




previous homenext

By default ArrayList is Object is non-synchronized but we can get synchronized version of ArrayList by using Collection class synchronizedList() method.
public static List synchronizedList(List l)


ArrayList l1=new ArrayList();


List l=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);