title: c++ Handling multiple threads in a main thread
body: <p>I am a bit new to multi threading, so forgive me if these questions are too trivial.</p>
  
  <p>My application needs to create multiple threads in a thread and perform actions from each thread.</p>
  
  <p>For example, I have a set of files to read, say 50 and I create a thread to read these files using CreateThread() function.</p>
  
  <p>Now this main thread creates 4 threads to access the file. 1st thread is given file 1, second file 2 and so on.</p>
  
  <p>After 1st thread completed reading file 1 and gives main thread the required data, main thread needs to invoke it with file 5 and obtain data from it. Similar goes for all other threads until all 50 files are read.</p>
  
  <p>After that, each thread is destroyed and finally my main thread is destroyed.</p>
  
  <p>The issue I am facing is:</p>
  
  <p>1) How to stop a thread to exit after file reading?</p>
  
  <p>2) How to invoke the thread again with other file name?</p>
  
  <p>3) How would my child thread give information to main thread?</p>
  
  <p>4) After a thread completes reading the file and returns the main thread a data, how main thread would know which thread has provided the data?</p>
  
  <p>Thanks</p>