I am creating an asynchronous class that logs strings into a file. Should I be creating the thread within the class itself? I was thinking something like this as a start function
void Async_Log::start (void)
{
  std::thread thread_log(
    [&]()
    {
      std::ofstream fout;
      fout.open(fileName);
      while(true)
      {
        if(q.size())
        {
          std::lock_guard<std::mutex> lock(m);
          fout << q.front() <<  "\t At Time: " << std::clock() << std::endl;
          q.pop();
        }
      }
      fout.close();
    });
}
Or would it be better to leave the threading up to main. My first concern is if threading is unique (so if I instantiate the class 2 times with two different files will the thread_log be over written or have a conflict).