Concurrent Collections
in Java |
Prof. David Bernstein
|
Computer Science Department |
bernstdh@jmu.edu |
size()
,
isEmpty()
) since all of the locks would have to
be acquired
ConcurrentHashMap
ConcurrentModificationException
LinkedBlockingQueue
BlockingQueue
interface):
Throws Exception | Returns Special | Blocks Until | Times Out | |
Insert |
add(e)
|
offer(e)
|
put(e)
|
offer(e, time, timeunit)
|
Remove |
remove()
|
poll()
|
take()
|
poll(time, timeunit)
|
Examine |
element()
|
peek()
|
|
|
LinkedBlockingQueue
Dispatcher
is used by
a DailyDispatchHandler
and
a RealTimeDispatchHandler
, each of which
executes in its own threaddispatch()
method
enters the waiting state if no vehicles are
availablemakeVehicleAvailable()
notifies the waiting
threadsDispatcher
uses
a LinkedBlockingQueue
ArrayBlockingQueue
:
LinkedBlockingDeque
(pronounced like "deck"):
PriorityBlockingQueue