C++ 以高效的方式在线程中获取备份文件

C++ 以高效的方式在线程中获取备份文件,c++,multithreading,performance,thread-safety,C++,Multithreading,Performance,Thread Safety,我需要以安全有效的方式在线程中创建备份文件。但是当线程成功完成最后一个任务时,它应该被触发 别理它 CreateBakeup函数被多次调用 bool CreateBakeup() { //here i create a OrignalFile and pass to thread for a backup. if (x_pthread_create (&pthreadId, NULL, makeBackup,

我需要以安全有效的方式在线程中创建备份文件。但是当线程成功完成最后一个任务时,它应该被触发 别理它

CreateBakeup函数被多次调用

bool CreateBakeup()
{

//here i create a OrignalFile and pass to thread for a backup.
if (x_pthread_create (&pthreadId, NULL,
                                makeBackup,
                               (void*)  OrignalFile) != 0)
        {

              std::cout<<"failed to create a thread"<<std::endl;
                return FALSE;
        }

}   
bool CreateBakeup()
{
//在这里,我创建一个原始文件并传递给线程进行备份。
如果(x_pthread_)创建(&pthread,NULL,
做备份,
(void*)原始文件)!=0)
{

为什么一点反应都没有。是什么不好,问题不清楚还是不好?为什么一点反应都没有。是什么不好,问题不清楚还是不好?
static void * makeBackup(void *OrignalFile)
{

 if ((pthread_mutex_lock(&keyMutex)) != 0)
        {
                std::cout<<"failed pthread_mutex_lock() "<<std::endl;
        }

 std::ifstream Orignal((char *)OrignalFile);

  std::ofstream fin("/backupfile");
  fin<<Orignal.rdbuf();
  remove((char *)OrignalFile)



   if ((pthread_mutex_unlock(&keyMutex)) != 0)
        {
          std::cout<<" failed pthread_mutex_unlock() "<<std::endl;
        }

}