c++ - When to use boost thread join function? -


I have recently been successful in creating a thread using boost :: bind function.

For some time, I am displaying the thread on stdout. If I use the thread I can see the output. However, if I do not do this, I do not see any output.

Why is this?

I hope that I do not have to use the ceremony, because I would like to call this function many times without waiting for the first launch thread without ending.

Thank you for your responses. I really wanted to make sure the thread was actually executed. So I added a system call to touch a non-existent file, and it was later, so Thread was executed.

If I use the thread I can see the output. However, if I do not do this, I do not see any output. Why is it like this?

Most likely that standard output buffering is a side effect on your system. Do you have '\ n' and / or endless perforated in each print statement? It should emphasize output ( endl plus flush stream).

If you look at the documentation, you will see that it is said to wait until the end of the function ends when a thread ends (or for that matter, a process) all Buffer output is flushed.

You do not have to wait until the thread completes the execution to see the output.

  • cout / stdout unbuffered, or
  • \ N and fflush (stdout) (for C-style I / O) or use std :: endl stream manipulator

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -