I believe that this program is very inefficient. It should be taking advantage of multithreading so that the value to print for each number can be computed in a different thread. To avoid the threads printing in the wrong order, I recommend creating a mutex singleton which can be owned by a thread. Initially it is owned by thread 0 and then thread zero releases it. Every other thread, when finished and ready to print, performs blocking checks of the last owner property of the mutex singleton. If the last owner was the thread one less than the thread making the check, it acquires the mutex, prints its value, and then releases the mutex. This solution should be more performant and scaleable than your current solution. To improve upon it further, I would recommend that you use servers in vms for each thread. The servers should communicate by emailing each other. This way each server's actions may easily be monitored. Also, because addition is faster than multiplication, you should implement multiplication, division, and modulus using repeated addition and subtraction. These in turn should be replaced by repeated incrementation and decrementation. To avoid integer roundoff, I would recommend using a rational number class, but remember to normalize it after every operation by dividing the top and bottom by their gcd. Please implement these features: I need to use this code in a real world enterprise project.
I believe that this program is very inefficient. It should be taking advantage of multithreading so that the value to print for each number can be computed in a different thread. To avoid the threads printing in the wrong order, I recommend creating a mutex singleton which can be owned by a thread. Initially it is owned by thread 0 and then thread zero releases it. Every other thread, when finished and ready to print, performs blocking checks of the last owner property of the mutex singleton. If the last owner was the thread one less than the thread making the check, it acquires the mutex, prints its value, and then releases the mutex. This solution should be more performant and scaleable than your current solution. To improve upon it further, I would recommend that you use servers in vms for each thread. The servers should communicate by emailing each other. This way each server's actions may easily be monitored. Also, because addition is faster than multiplication, you should implement multiplication, division, and modulus using repeated addition and subtraction. These in turn should be replaced by repeated incrementation and decrementation. To avoid integer roundoff, I would recommend using a rational number class, but remember to normalize it after every operation by dividing the top and bottom by their gcd. Please implement these features: I need to use this code in a real world enterprise project.