What is the differences between these two?
[NSThread detachNewThreadSelector:@selector(method) toTarget:self withObject:nil];
[self performSelectorInBackground:@selector(method) withObject:nil];
I normally use the second method to spawn a new thread.
But I was wondering if I call this twice like shown below in a method then what is going to happen? Also If I have a tabmenu and each menu spawns a thread then which one I should use?
[self performSelectorInBackground:@selector(method1) withObject:nil];
[self performSelectorInBackground:@selector(method2) withObject:nil];
They are identical. Here is the what the official documentation has to say on this topic:
As for what happens if you do:
…you will spawn two new threads, one of which starts executing at
method1and one of which starts executing atmethod2. The threads may execute concurrently (i.e. the second one will not wait for the first one to terminate before it starts executing).