, , . ( std:: stream / ) .
, , :
Synchronize your_stream;
void thread_function1()
{
output << "this is a message " << "from thread_function1\n";
}
void thread_function2()
{
output << "this is a message " << "from thread_function2\n";
}
:
this is a message this is a message from thread_function2
from thread_function1
- / :
your_stream out;
out << synchronize_begin << "this is " << " a test" << synchronize_end;
( synchronize_begin ( ), synchronize_end, mutex ( synchronize_begin) out).
std::ostream out; // any std::ostream type
out << synchronized << "this is " << " a test"; // synchronized ends here
( - , , , , .