Package java.util
Class Collections
static Set synchronizedSet(Set s)
_INSERT_METHOD_SIGNATURE_HERE_
Description:
Returns a synchronized (thread-safe) set backed by the specified set. Changes in the returned set are reflected in this set, and vice-versa. In order to guarantee serial access, it is critical that all access to the backing set is accomplished through the returned set.
The user has to manually synchronize on the returned set when iterating over it:
synchronized(MySet) { // iterate in a synchronized block
Iterator i = MySet.iterator();
while (i.hasNext())
myFun(i.next());
}
The returned collection will be serializable if the specified set is serializable.