|
Synchronized Collections
in Java |
|
Prof. David Bernstein
|
| Computer Science Department |
| bernstdh@jmu.edu |
Dispatcher is used by
a DailyDispatchHandler and
a RealTimeDispatchHandler, each of which
executes in its own threadDispatcher had synchronized
dispatch() and makeVehicleAvailable()
methodsDispatcher uses a synchronized
List
Collection is changed
while using an Iterator
(or a for-each loop)?Iterator object's
hasNext() or next() method
will throw a ConcurrentModificationException
Iterator objects are said to
fail-fast
toArray() and iterate over the array