Let me state up front that this is a homework assignment.
I'm supposed to take a simple task (flipping a coin n number of times) and use threading to increase the execution speed of the program. The basic idea is that to flip a coin 1,000,000 times, you could launch n threads and have it execute approx. n times as fast.
I've been working on it for a few days. The code is complete in that the task gets divided up and runs on multiple threads. However, the execution time doesn't nearly reflect what I would expect it to be.
For example, flipping 10,000,000 "coins" takes:
~700ms using 1 thread.
~980ms using 2 threads.
~920ms using 4 threads.
I would expect that the execution time would decrease as I add more threads. This time difference is magnified as I increase the number of coin flips. For example, flipping 100,000,000 "coins" takes:
~7 seconds using 1 thread.
~10 seconds using 2 threads.
Does this make sense?
I appreciate your time and any thoughts you might have. Thanks!