Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why consumer thread is not starting?

 
raja singh kumar
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont know why my consumer/producer program is not working. I have a producer which uses a for loop to produce 10 values and a consumer to consume the value but after the first element is produced the program keeps running forever without any output. I dont know what is the problem. What exactly am I doing wrong? How do I fix the issue?








 
Henry Wong
author
Sheriff
Posts: 22607
111
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
raja singh kumar wrote:What exactly am I doing wrong? How do I fix the issue?


It would be a good idea for your producer and consumer to share the same data holder. Otherwise, there is no communication.

Henry
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!