+ 2

Can someone help with multithreading-issues?

See my code below: 1.) How to verify the multithreading? 2.) Is it Sololearn or is it std::cout or is it my code that prevents it from working? 3.) How to implement mutex? https://code.sololearn.com/c2hf8Wq6uliS/?ref=app

18th Feb 2019, 9:42 PM
aaaa
3 Answers
+ 1
I expected the output to be different numbers. Something like this: „6 / 8 / 9 / 9 / 12 / ...“. But instead the code sometimes produces a lot of 6es and sometimes it produces just 36es. My interpretation of this output is, that the two threads are not running parallel. For me it seams as if the functions „CountUp“ and „PriCount“ are running one after another in random order. I‘m using std::thread or what do you mean with approach?
20th Feb 2019, 11:09 PM
aaaa
0
Which approach of multithreading are you using?
20th Feb 2019, 3:47 AM
Mohd Zaki
Mohd Zaki - avatar
0
Question 1 and 2 are solved. But I still need the mutex.
23rd Feb 2019, 8:03 PM
aaaa