Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unsynchronized Producer Consumer Problem

807606Apr 1 2007 — edited Apr 2 2007
Hi I would like some help implementing an unsynchronized producer consumer with an unbounded queue (implemented using an ArrayList) I have both the producer and consumer sleeping for random amount of time (producer wakes up faster). The problem is that sometimes the producer never gives the consumer a chance to run.

Note I have a notify after I add stuff to the ArrayList. I dont know whether its my choice of collection object or the fact that I have not defined a wait for the producer.

I don't know whether I have explained my problem clearly so feel free to ask some questions. Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 30 2007
Added on Apr 1 2007
4 comments
366 views