Search code examples
c++stringc++11stdthread

Behind the scenes of construction of a thread


It is known that how to use thread. But how is the thread library implemented. I mean, like we have std::string, its functionality can be somewhat replicated, by user himself using C-strings (char arrays), it is easy.

My question is how can i achieve this for the case of thread, like how can i create a class with bare-minimum C++ datatypes and functions(without WINAPI), std::thread like functionality into a class.

I would like to give a example, my teacher has prohibited me from using std::string, and allowed to only use C-strings, but i can use OOP concepts..

class string_my
{  
      private:
            char* str;
      public:
         // all the required func. to store the value in char*
 }

Solution

  • You cannot implement a thread class without either using the OS provided threading primitives or some higher level threading library (like boost::thread or std::thread) that in turn rely on said OS-provided threading primitives.