/** Maintains a list of names. */
public class NameManager {
private Listnames = new ArrayList ();
/** Stores a new list of names. This method is threadsafe. */
public void setNames(ListnewNames) {
synchronized (names) {
names = new ArrayList();
for (String name : newNames) {
names.add(name);
}
}
}
Продолжение:
http://google-opensource.blogspot.com/2009/10/testing-race-conditions-in-java.html
Комментариев нет:
Отправить комментарий