|
|
User login
Feeds |
Problem in using the same thread again.
|
|||||
| Wed, 2005-08-03 14:05 | |
|
Hello Again,
I am facing a problem with using the same thread again. Following are the steps. 1. Create and resume the thread, which just prints sth. 2. Wait for 4-5 seconds just to make sure that the created thread has completed printing. 3. Again create same thread with the same name and same arguments. Below is the code. RThread Thrd; TInt err = Thrd.Create(NAME ,...,...,..., Ptr); RDebug::Printf("Create Returned %d", err); Thrd.Resume(); //This will start the thread which just prints sth User::After(5000000); //wait for 5 seconds to make sure that the thread has completed printing err = Thrd.Create(NAME ,...,...,..., Ptr); RDebug::Printf("Create Returned %d", err); Now here comes the problem, When i create thread second time it returns with error -11, means already exist. So this way i am not able to use the same thread second time. Assuming it exists already, i tried to call Resume() directly(Without creating the thread) second time but now it does nothing. What could be the reason for this behaviour? Did i miss something?? Please Help in this regard, Thanks Pinky |
|
Forum posts: 35
I have solved the problem now. Was not closing the kernel side object for the thread before creating it second time.
Thanks Anyways,
Pinky
Forum posts: 1
My code looks like this:
iWorkerThread = new (ELeave) RThread();
pH = User::ChunkHeap(NULL,0x1000,0x100000);
err = iWorkerThread->Create( _L("activeThread"), DoWorkFunction, KDefaultStackSize,pH, this );
iWorkerThread->Close();
delete iWorkerThread;
iWorkerThread = NULL;
but when I re-execute the same code, error -11 throws.
so, could u help to tell me the right way to free sub thread's memory. thank you.