[concurrency-interest] Strange behavior with LinkedBlockingQueue

David Holmes dholmes@dltech.com.au
Wed, 27 Oct 2004 09:42:51 +1000

I wrote:
> There is no guarantee that Thread.yield will actually do anything. Unless
> your consumer blocks for some other reason, it can run forever without he
> producer getting a further chance to run. yield() is just a hint to the
> scheduler, you can not rely on it to guarantee progression.
> Similarly, priorities are just hints - and in the JDK on certain systems,
> have quite unexpected affects these days. (See the release notes)
> Either change the yield to a sleep, or else utilise the blocking take()
> method to ensure producer and consumer coordinate their actions properly.

That does not seem to be the problem. I replaced the yield with a sleep and
it still goes into a count=0 loop. It is as if something is silently killing
or hanging the producer. Very odd.

David Holmes