Threads

Creating a Thread

You create a new thread by building an instance of the class IlsThread.

IlsThread* workerThread = new IlsThread(workerProc, workerData);

Once a thread has been created, the start procedure associated with the thread— workerProc in this case—is invoked with the pointer to the thread data as its argument:

static void

workerProc(IlsAny data)

{

myData* workerData = (myData *) data;

...

}

Note

The start procedure will not necessarily be run immediately after the thread has been created. This depends on the scheduler of the operating system you are using.

Once a thread has been started, it exists until either the start procedure returns or the thread calls the static member function IlsThread::ExitCurrentThread. The class IlsThread is just a placeholder for the information related to the thread. It also provides access to the member functions associated with an instance of a thread. Deleting an instance of IlsThread does not stop nor delete the thread.