title: Define Threads in Visual Studio 2010
body: <p>I want to create a C++ application in Visual Studio 2010 which contains 2 threads:</p>
  
  <ol>
  <li>read data from a extern file</li>
  <li>write data to an extern file</li>
  </ol>
  
  <p>I already read the theory about threading but don't really understand how I can use it. Is there anybody who can show me how I can simply define and run these 2 threads in Visual Studio 2010? </p>
  
  <p>Currently I have the following example which doesn't work:</p>
  
  <pre><code>class Thread
  {
     public:
        Thread();
        int Start(void * arg);
     protected:
        int Run(void * arg);
        static void * EntryPoint(void*);
        virtual void Setup();
        virtual void Execute(void*);
        void * Arg() const {return Arg_;}
        void Arg(void* a){Arg_ = a;}
     private:
        THREADID ThreadId_;
        void * Arg_;
  
  };
  
  Thread::Thread() {}
  
  int Thread::Start(void * arg)
  {
     Arg(arg); // store user data
     int code = thread_create(Thread::EntryPoint, this, &amp; ThreadId_);
     return code;
  }
  
  int Thread::Run(void * arg)
  {
     Setup();
     Execute( arg );
  }
  
  /*static */
  void * Thread::EntryPoint(void * pthis)
  {
     Thread * pt = (Thread*)pthis;
     pt-&gt;Run( pt-&gt;Arg() );
  }
  
  virtual void Thread::Setup()
  {  
      // Do any setup here
  }
  
  virtual void Thread::Execute(void* arg)
  {
          // Your code goes here
  }
  </code></pre>
  
  <p>I am also open for good tutorials or code examples.</p>