Имеем
| Код | void fuck() { boost::mutex::scoped_lock lock(io_mutex); cout << "Hello, world" << endl; };
int main() { cout << "Begin" << endl; boost::thread thrd1(&fuck); boost::thread thrd2(&fuck); boost::thread thrd3(&fuck); cout << "Before thrd1" << endl; thrd1.join(); cout << "Before thrd2" << endl; thrd2.join(); cout << "Before thrd3" << endl; thrd3.join(); cout << "End" << endl; return 0; }
|
Вывод:
| Код | Begin Hello, world Hello, world Before thrd1 Before thrd2 Before thrd3 Hello, world End
|
Почему не
| Код | Begin Before thrd1 Hello, world Before thrd2 Hello, world Before thrd3 Hello, world End
|
?
|