I run the following program on a 32-core computer:
#include<iostream>
- Reading lines 24, 26, and 32 takes 9 seconds.
- If only lines 24, 26 are commented out and 32 are uncommented, it takes another 9 seconds.
- No comment comments takes 18 seconds to complete
I thought the two threads are independent, and it doesn't matter if there is a lock on the a.foo() or not. But it is so, why?
c ++ multithreading mutex boost-mutex boost-thread
cpp
source share