title: After closing the file, I do not have access to it
body: <p>I use this code in a multithreaded program:</p>
  
  <pre><code>class A{
  public:
      FILE *File;
      bool ThFunc(){
          if (CreateDataFile())
              std::cout &lt;&lt; "File was created\n";
          else{
              std::cout &lt;&lt; "Can't create file\n";
              return false;
          }
  
          //work with file
  
          if (CloseDataFile()){
              std::cout &lt;&lt; "File was closed\n";
              return true;
          }
          else{ 
              std::cout &lt;&lt; "Can't close file\n";
              return false;
          };
      };
  
      bool CreateDataFile(){
          File = fopen ("binary_file.bin", "wb");
          if (File!=NULL)
              return true;
          else
              return false;
      };
  
      bool CloseDataFile(){
          int t=fclose(File);
          if (t!=0)
              return false;
          else{
              //insert the file name in another thread
              return true;
          }
      }
  };
  </code></pre>
  
  <p>Sometimes, in another thread (~every 10 files) there is an error: "The file is used by another program(my.exe)", but in console i see: "File was closed". What could be wrong? Mutex is locked, before use a ThFunc() and unlocked after.</p>