Originally Posted by
copeg
You are calling a static function Math.random within several threads. This function is most-likely thread-safe although I don't have time right not to verify this. So basically, when more than one thread is created, when each thread tries this function - if another thread is using it - it will have to wait until the lock is released. Suggestion, create an instance variable of Random in your coin flip class. This should result in expected behavior if the above is correct
You're a lifesaver! Math.random() was the problem.
I changed my program to use the nextBoolean() method in the random class, and I now see approx. a 2 times speed up when using 2 threads vs. 1. Thanks so much for your comments and advice.