multithreading - What is the difference between +[NSThread detachNewThreadSelector:toTarget:withObject:] and -[NSObject performSelectorInBackground:withObject:]? -


they seem perform reasonably similar task: launching new thread performs selector , easily. there differences? maybe regards memory management?

both identical.

in ios , mac os x v10.5 , later, objects have ability spawn new thread , use execute 1 of methods. performselectorinbackground:withobject: method creates new detached thread , uses specified method entry point new thread. example, if have object (represented variable myobj) , object has method called dosomething want run in background thread, could use following code that:

[myobj performselectorinbackground:@selector(dosomething) withobject:nil]; 

the effect of calling method same if called detachnewthreadselector:totarget:withobject: method of nsthread current object, selector, , parameter object parameters. new thread spawned using default configuration , begins running. inside selector, must configure thread thread. example, need set autorelease pool (if not using garbage collection) , configure thread’s run loop if planned use it. information on how configure new threads


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -