person man wrote:
> For implementing thread in most of the example I saw a run() function is
> overloaded. Example is given here :
>
> ////////////////////////code////////////////
> #include <iostream>
> #include "thread.h"
> class MyThread : public kbcafe::thread
> {
> public:
> virtual void run()
> {
> std::cout << "Hello" << std::endl;
> };
> };
> int main(int argc, char* argv[])
> {
> MyThread thread;
> thread.start();
> ::Sleep(1000);
> return 0;
> }
>
>
> But how can i implement my own application. Suppose i have two or more
> objects. I want to implement them using thread.
> I am very new in c++. Plz, help me giving an example....................
Block/STL vector of MyThread.
size_t x;
Block<MyThread> Threads;
Threads.SetSize(10);
for (x = 0; x < 10; x++) Threads[x].start();
for (x = 0; x < 10; x++) Threads[x].wait();
return 0;
Sleep() is a terrible method of synchronizing thread objects.
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* VerifyMyPC 2.5
Change tracking and management tool.
Reduce tech. support times from 2 hours to 5 minutes.
http://www.CubicleSoft.com/VerifyMyPC/