Conditionally join threads

No, the second condition is not hardcoded, it's a user input. The use case is the following:

  1. Spawn thread A which reads data from a server.
  2. Check if the user passed a command line option.
  3. If the option was passed, then join thread A and check it's data against user input. It could conditionally exit the program and the rest of the main won't execute.
  4. If NO option was passed, do some other work in the main thread and later join the A thread and work with it.

Important note. If step 3 happened, and we didn't exit, the data from the thread must be of course available is in the scope of main, so in step 4 we should not join again.
So basically I want to allow the main thread to do some work until the data of thread A is needed.
Hope it helps to get the idea. :slight_smile:

thread_join