The methods of Vector are synchronized.
import java.util.Iterator;
import java.util.Vector;
public class MainClass {
public static void main(String[] argv) {
Vector vec = new Vector();
for (int i = 101; i <= 110; i++)
vec.add(i);
Iterator iter = vec.iterator();
while (iter.hasNext())
System.out.println(iter.next());
}
}
|