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 insimple, 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

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -