Just to add....... You could add synchronization to a class that
is not synchronized by using some static factory methods defined within the Collections class (not to be confused with the Collections interface). You could essentially use an ArrayList and get the same thread saftey that the Vector and Hashtable classes provide using this approach.![]()
Code:List synclist = Collections.synchronizedList(somelist); synchronized(synclist){ for(Iterator i = synclist.iterator();i.hasNext();) doSomthing(i.next()) }




Reply With Quote