mardi 24 mars 2020

Threads and sum of random numbers

How do I make one thread store random numbers in shared memory and the other reads those numbers and prints the sum?

I made 2 threads, and I know how to write sum, but I am probably doing something wrong with the printing random numbers because it doesn't want to print them. I need two inputs/threads N and M. N is generating random numbers and stores them in shared memory. The other is M. I also need to make that the code repeats M more times with M being the second input argument of the program at its startup.

my code looks like this. It's a mess.

enter image description here




Aucun commentaire:

Enregistrer un commentaire