Get Synchronized Set from HashSet in Java
Description
The following code shows how to get Synchronized Set from HashSet.
Example
//from www . j a va 2s . c o m
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
public class Main {
public static void main(String[] args) {
HashSet hashSet = new HashSet();
Set set = Collections.synchronizedSet(hashSet);
System.out.println(set);
}
}
The code above generates the following result.