I wrote a multi-threaded program that randomly generates strings, and after generating, checks to see if the string contains a certain value. Namely, StringGenerator
and StringChecker
. What I'm trying to figure out is how many StringGenerator
threads I would need in order to keep StringChecker
busy.
All StringGenerator
threads have a reference to a Queue
that contains all of the Strings needed to be checked, and when they generate a String, it gets added to the Queue
. All StringChecker
threads also have a reference to the same Queue
and poll it to get the next string, and checks to see if it contains the keyword.
Because generating the Strings takes more time than checking them, what I want to know is if there are any equations, algorithms or analyses that can be done on the code that can help tell me approximately how many threads of each I will need such that the sum of all Strings generated by the StringGenerator
s is as close to the number of strings checked by the StringChecker
s as possible.