Take the 2-minute tour ×

I want to know what is difference between perform selector in backgorund and detachNewThread

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

I would look at it from a semantic point of view. There is no technical reason to use one or the other.

Use NSThread if you actually "think" of having a thread that "does something"; in particular, it will probably be the most appropiate way of creating a thread if your thread runs some form of event- or messaging loop. In such a case, the "thread object" is really just that; in many cases it's not an "application realm" object with actual application data, as these will be handed over to the thread in some way.

Use the NSObject-based methods if your thread is merely meant to run some single operation in the background. You don't really care about this being a "thread", and the object that you run this on is likely to be the "application realm" object with the data; there's no event- or messageloop to feed it commands from other threads.

Thus, I would base the decision on abstract factors, as in "what looks better in the given context". Having an NSThread "feels" like a more detached entity that is willing to offer services to multiple clients, whereas the NSObject method feels like it's closely attached to the data object that it runs with, and doesn't really deal with anything else unless it's vital to the cause.

share|improve this answer
add comment

They Are identical. as you can see in Documentation section Click Here


performSelectorInBackground:withObject: is easier way rather than NSThread.

However, NSThread can control its priority, stacksize, etc. If you'd like to customize the behavior, I recommend NSThread instead of performSelectorInBackground:withObject:.

share|improve this answer
note: stack and priority manipulations are things one might do only very very very rarely. it's best to use the defaults in the majority of cases. –  justin Aug 18 '12 at 10:17
Stop spamming!! stackoverflow.com/a/2095100/1059705 & stackoverflow.com/a/2099175/1059705 , Direct them to that link instead –  Bala Nov 15 '12 at 11:55
add comment

Your Answer


