Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

queue issue

 
jack nicolson
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am facing one issue with the LinkedBlockingQueue, I wrote two threads one producer and one consumer. These threads are running in the background. At a particular time the producer thread retrieves the data from the Database and sets the pojo objects. these objects put into queue.

Now, consumer thread retrieving the objects from queue, how ever its not happening, some times consumer retrieve one object from queue.

As of my understanding the consumer should retrieve the object from queue as soon as its put by the producer,

Both the thread are running continuously.


Jack *
 
Justin Yao
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about show us your Producer and Consumer?

But you can take a look at the Producer and Comsumer pattern first.
http://www.java2s.com/Code/Java/Threads/ProducerandComsumer.htm
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic