Question on thread communication
Question on thread communication
- Subject: Question on thread communication
- From: Karim Morsy <email@hidden>
- Date: Mon, 20 Mar 2006 20:39:42 +0100
Hi,
I'm having an app in which several threads need to communicate with
each other.
I've done this as follows:
on the main thread I detach a new thread that performs a task. upon
completion of the thread the main thread should perform subsequent
steps. it shouldn't do so unless the detached thread has really
finished execution. for the detached thread to signal to the main
thread that it's done, I do this:
NSNotificationCenter *nc= [NSNotificationCenter defaultCenter];
NSNotification *n= [NSNotification notificationWithName:
KMFileInitCompletedNotification object:self];
[nc performSelectorOnMainThread:@selector(postNotification:)
withObject:n waitUntilDone:YES];
[pool release];
the completion steps are then performed by the main thread in the
appropriate handler method.
so the questions I have are:
- is there anything problematic about this approach ?
- is there an easier/better way to do this ?
many thanks in advance,
Karim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden