On May 29, 2004, at 12:18 AM, Philip Mötteli wrote:
I have no idea how to recognize this just created thread later,
when it terminates. What I need is something like a handle. I mean
objc_thread_detach() gives back an objc_thread_t too.
I could put some flag into the tread dictionary, but it would be so
much nicer to be able to just ask the thread for its handle or to
keep the address of the NSThread instance.
Here's an idea: Send a notification to the main thread using
-performSelectorOnMainThread: with the NSThread object (using
NSThread's +currentThread class method to obtain an address) as the
notification's embedded object. I don't see why that wouldn't work,
Good idea, but I create a lot of threads from different objects. How
can I be sure, that not in the same moment (or slightly before or
afterwards) another thread is forking a thread, so sending this
notification? Or, as far as I know, performInMainThread would be
executed, when the main thread enters the next time the runloop. So I
could have forked several other threads, which' notifications would
then be subsequently queued in the event queue.
Written in Mail.app:
extern NSMutableDictionary *managedThreads; // assume this exists
- (void)detachManagedThreadSelector:(SEL)selector toTarget:(id)target
withObject:(id)identifier