package com.usr.collections;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class SynchonizedList {
public static void main(String[] args) {
List<String> list = new ArrayList<String>();
list.add("one");
list.add("two");
list.add("three");
list.add("four");
list.add("five");
// static void synchronizedList(List list) method returns a synchronized
// list from the provided ArrayList
List<String> synList = Collections.synchronizedList(list);
System.out.println("sysnchorinzed list elements are:" + synList);
}
}
output
sysnchorinzed list elements are:[one, two, three, four, five]
No comments:
Post a Comment
Note: only a member of this blog may post a comment.