+ 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
3 ответов
+ 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?
0
Which approach of multithreading are you using?
0
Question 1 and 2 are solved. But I still need the mutex.