I need some help with this Producer Consumer Controller code.
I need to perform Task A on all the records of an input file. Input file may contain millions of records.
I need to be able to run this process at a steady thread count of say 20 threads.
I wrote three classes - Producer, Consumer and Controller
I do not know how to make the program wait till the producer and consumer completes their task and then exit the VM.
If I set the threadcount less than the number of records in the file, the program exits properly after processing all the records.
If I set threadcount equal to the number of records in file, the program never exits, even though all the records were processed.
Can someone please tell me how to get past this, Thank you.
Thank you Jim, Mike was right on the mark, removing join statement on the consumer made it work.
It would be great, if you can help me in the same app how to vary number of consumer threads at run time.
E.g. Increase/Decrease the consumer count based on TPS.
Lets say, i started this process, with 10 consumers and i find that based on some parameters that i can start few more consumers or reduce the number of consumers, how can i do that, Please advice.
Kasi : Can you read a parameter file periodically, or pass in a queue size on the command
line at start-up? You could then construct a new (larger/smaller) blocking queue, transfer
any pending jobs to it, and shut down the old queue. What do you think?