2015-04-20 15:36:01 -07:00
|
|
|
|
//: containers/Synchronization.java
|
2015-05-29 14:18:51 -07:00
|
|
|
|
// <20>2015 MindView LLC: see Copyright.txt
|
2015-04-20 15:36:01 -07:00
|
|
|
|
// Using the Collections.synchronized methods.
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
public class Synchronization {
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
Collection<String> c =
|
|
|
|
|
Collections.synchronizedCollection(
|
2015-05-05 11:20:13 -07:00
|
|
|
|
new ArrayList<>());
|
2015-04-20 15:36:01 -07:00
|
|
|
|
List<String> list = Collections.synchronizedList(
|
2015-05-05 11:20:13 -07:00
|
|
|
|
new ArrayList<>());
|
2015-04-20 15:36:01 -07:00
|
|
|
|
Set<String> s = Collections.synchronizedSet(
|
2015-05-05 11:20:13 -07:00
|
|
|
|
new HashSet<>());
|
2015-04-20 15:36:01 -07:00
|
|
|
|
Set<String> ss = Collections.synchronizedSortedSet(
|
2015-05-05 11:20:13 -07:00
|
|
|
|
new TreeSet<>());
|
2015-04-20 15:36:01 -07:00
|
|
|
|
Map<String,String> m = Collections.synchronizedMap(
|
2015-05-05 11:20:13 -07:00
|
|
|
|
new HashMap<>());
|
2015-04-20 15:36:01 -07:00
|
|
|
|
Map<String,String> sm =
|
2015-05-05 11:20:13 -07:00
|
|
|
|
Collections.synchronizedSortedMap(new TreeMap<>());
|
2015-04-20 15:36:01 -07:00
|
|
|
|
}
|
|
|
|
|
} ///:~
|