Re: multithreading.
<> wrote in message
hello everyone,
i want to use multithreading in c++,i have no previous experience of
implementing multithreading but from my operating system concepts i
know few concepts of multithreading .
can anyone please guide me how and were to begin from.
all help is apprecitated.
thank you
mohan gupta
Multithreading has in my opinion two ways of applying C++ virtual functions:
(1) the thread caller function (e.g. in win32):
DWORD CALLBACK thread_call( void * arg )
{ base_thread * p = (base_thread *)arg;
( *p )();
}
where class base_thread has a pure virtual operator()():
virtual operator()() = 0;
and derive the different thread call classes from base_thread,
implementing different operator()(),
(2) the multi-threading class:
class multi_thread
{ base_thread * * the_threads;
public:
multi_thread( unsigned int );
~multi_thread();
void set_thread( unsigned int, base_thread * );
virtual void start_threads() = 0;
virtual void wait_threads() = 0;
virtual void close_threads() = 0;
}
multi_thread::multi_thread( unsigned int n )
{ the_threads = new base_thread * [ n ];
} etc.
and derive the different win32/pthread etc. implementations.
This way C++ runtime polymorphism is set to work in multithreading.
Maarten.