Le 9 déc. 08 à 21:36, John Love a écrit :

Reference:

http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/chapter_6_section_5.html#/ /apple_ref/doc/uid/10000057i-CH16-SW7

I've got several questions since I'm just starting to investigate Mach Ports.

1) Why is +LaunchThreadWithPort: so designated, ie, a class method. It seems to me that as far as the specific code listings presented, a class method is not required? For example, [workerObj sendCheckinMessage:distantPort] could be replaced with [self sendCheckinMessage:distantPort] if LaunchThreadWithPort would be changed to an instance method.

2) Maybe the real question #1 is: What exactly is the object in the background thread, named workerObj ??

An arbitrary object that perform some long works that should be execute in a background thread. "Worker" is a very common term in multithreading programming.


3) I've saved my most general question to last, at least for this trip: currently when I enter my method to start up my background thread or threads, I simply call (several times if I have multiple threads:

[NSThread detachNewThreadSelector:@selector(bgCalcThread:) toTarget:self withObject:nil]

If I have multiple background threads, I can use a NSMutableDictionary with multiple keys for inter-thread communication


I think I miss something in the NSDictionary reference. I though it was not thread safe, and I never saw any reference to synchronisation or communication methods. What do you mean by "using dictionary for inter thread communication" ?

So, what do Mach Ports give me that the above doesn't?

A channel to send arbitrary message to another thread (of course, it can also be done using performOnThread methods).


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to