While other suggested solutions work, If you really want the solution to be made thread safe you should replace ArrayList with CopyOnWriteArrayList
//List s = new ArrayList<>(); //Will throw exception
List s = new CopyOnWriteArrayList<>();
s.add("B");
Iterator it = s.iterator();
s.add("A");
//Below removes only "B" from List
while (it.hasNext()) {
s.remove(it.next());
}
System.out.println(s);