I’ve implemented something similar to consumer-producer problem using a unbounded linked blocking queue. I have the producer putting objects to the queue and consumers taking it. When I tested the program, doubling the amound of thread each trial while still processing the same amount of objects, the time for all trials seems to be constant. Is it suppose to be constant? Or more thread means faster processing? Not sure if it is my code that is causing the slowness or the synchonization for the shared resource. Any ideas?
I’ve implemented something similar to consumer-producer problem using a unbounded linked blocking queue. I
Share
It entirely depends on what the bottleneck is:
You need to look at what’s going on while your program is running:
Then analyze what your code is doing, and work out what how parallelizable you expect the problem to be