• Post Reply Bookmark Topic Watch Topic
  • New Topic

Consumer starts after producer has finished his work  RSS feed

 
David Freed
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a JPA project, I have two threads: producer and consumer.

Producer should get the search result of twitter query from another class and put it in a LinkedBlockingQueue, thread consumer should consume the result and use another class to persist them to MYSQL.

Producer shouuld not stop when there is a jam for consumer in persisting the results to MySQL.

**Problem** : The producer always produces all the expected results and after that consumer starts to consume.

If other information is needed, I will provide here.


Thank you in advance for your suggestions.



Here I show you first the main class, producer and consumer :

**Main** Class:



**Producer** thread:




**Consumer** Thread:






 
Henry Wong
author
Sheriff
Posts: 22853
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Freed wrote:
**Problem** : The producer always produces all the expected results and after that consumer starts to consume.


How long does it take for the producer to produce all the results? In your example, the producer is given some time before the consumers starts -- is it enough time?

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!