• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Perform selector on thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Perform selector on thread


  • Subject: Re: Perform selector on thread
  • From: Tony Becker <email@hidden>
  • Date: Mon, 24 Mar 2008 08:35:44 -0400

Eddy:
In response to your question, yes, it is necessary.
It turns out that many things aren't "thread-safe". This means you can't simply spawn many threads from the "main" thread and have them successfully interact (message) to objects in other threads in all cases. Some really weird, hard to track/fix problems occur if you don't manage the thread messaging.
So, the recommended way of messaging in a "callback" to your "parent" thread, which is normally the main thread, is:


- (void)performSelectorOnMainThread:(SEL)aSelector withObject: (id)arg waitUntilDone:(BOOL)wait

Appkit is one of those things that is not thread safe, if I remember correctly:
http://www.cocoadev.com/index.pl?AppKit




On Mar 24, 2008, at 7:45 AM, John C. Randolph wrote:


On Mar 24, 2008, at 4:19 AM, Eddy Hatcher wrote:
Hi,

I am detaching a selector "A" on a separate thread in another class. In this selector I am calling another selector "B" in the same class using [self performSelector:@selector(B)];

Which thread will this selector "B" be run on? The main, or the one i created for "A".

Any messages you send will be performed on the same thread unless you explicitly dispatch them to another thread.


-jcr
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Perform selector on thread
      • From: Mike <email@hidden>
References: 
 >Perform selector on thread (From: Eddy Hatcher <email@hidden>)
 >Re: Perform selector on thread (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: Re: Beginner with Cocoa
  • Next by Date: Re: Beginner with Cocoa
  • Previous by thread: Re: Perform selector on thread
  • Next by thread: Re: Perform selector on thread
  • Index(es):
    • Date
    • Thread