java - concurrentLinkedQueue offer/poll blocking -
does offer blocks poll or vice versa ? meaning , can producer offer , @ same time consumer trying poll ? or if producer offering , queue blocks till done ?
object a
while (true){ inputqueue.offer(newpartlist); }
object b
while (true){ inputqueue.poll(newpartlist); }
no, not. use linkedblockingdeque instead. remember use methods blockingdequeue or blockingqueue interfaces values. these methods implemented blocking.
update
neither offer
nor poll
methods blocking. in linked interfaces put*
, take*
methods implemented blocking. put
blocks long queue full, take
blocks if queue empty.
now see asking else. in linkedblockingdeque calling offer
blocks poll
, because implementation has inernal lock
synchronizing access. in concurrentlinkedqueue's javadoc explicitly stated, that:
this implementation employs efficient "wait-free" algorithm based on 1 described in
simple, fast, , practical non-blocking , blocking concurrent queue algorithmsby maged m. michael , michael l. scott.
which suggests these operations don't block each other. if interested, suggest reading paper more insight.
Comments
Post a Comment