How to get a synchronized Set from HashSet using synchronizedSet method of Collections class - Java Collection Framework

Java examples for Collection Framework:HashSet

Description

How to get a synchronized Set from HashSet using synchronizedSet method of Collections class

Demo Code



import java.util.HashSet;
import java.util.Collections;
import java.util.Set;
 
public class Main {
 
  public static void main(String[] args) {

    HashSet hashSet = new HashSet();
   /*from   w  w w.  j a  v  a 2 s.c om*/
    Set set = Collections.synchronizedSet(hashSet);
   
  }
}

Related Tutorials