Hi,i would like to ask how can i know when the threads is complete?
Example:
Here i create 5 different thread use the same function,with iThread, how can i know are Thread1/Thread2/Thread3 completed;TBuf<32> threadName;
TInt iThreadCount=5;
while(iThreadCount>0)
{
//Create 5 different thread.
threadName.AppendFormat(_L("Thread%d"),iThreadCount);
iThread =RThread();//Get the handler of main thread.
iThread.Create(threadName,ThreadFunction,4096,KMinHeapSize,
256*KMinHeapSize,this);
iThread.Resume;
iThreadCount--;
}
I know this method can get the exittype of iThread,TBool IsAlive(thread id or thread name)
{
TBool alive = EFalse;
RThread thread;
TInt err = thread.Open(thread id or thread name);
if(err==KErrNone)
{
TExitType exitType = thread.ExitType();
if(exitType==EExitPending) // thread is still alive
{
alive = ETrue;
}
}
return alive;
}
I just want to know if i use this way:
The status is Thread1's status?TInt err = iThread.Open(Thread1);
if(err==KErrNone)
{
TExitType exitType = iThread.ExitType();
if(exitType==EExitPending) // thread is still alive
{
alive = ETrue;
}
}

Reply With Quote


