0 votes
16 views

Does a thread created using performSelectorInBackground:withObject: creates its own autorelease pool?

in Technology by (189k points)

1 Answer

0 votes

The performSelectorInBackground:withObject: method creates a new detached thread and uses the specified method as the entry point for the new thread. For example, if you have some object (represented by the variable myObj) and that object has a method called doSomething that you want to run in a background thread, you could could use the following code to do that:

[myObj performSelectorInBackground:@selector(doSomething) withObject:nil];

The effect of calling this method is the same as if you called the detachNewThreadSelector:toTarget:withObject: method of NSThread with the current object, selector, and parameter object as parameters. The new thread is spawned immediately using the default configuration and begins running. Inside the selector, you must configure the thread just as you would any thread. For example, you would need to set up an autorelease pool (if you were not using garbage collection) and configure the thread’s run loop if you planned to use it. For information on how to configure new threads, see “Configuring Thread Attributes.”

by (189k points)

Related questions

0 votes
1 answer 15 views
15 views asked Oct 30, 2020 in Technology by JackTerrance (189k points)
0 votes
1 answer 16 views
16 views asked Nov 10, 2020 in Technology by JackTerrance (189k points)
0 votes
1 answer 13 views
13 views asked Nov 10, 2020 in Technology by JackTerrance (189k points)
0 votes
1 answer 11 views
0 votes
1 answer 14 views
14 views asked Nov 10, 2020 in Technology by JackTerrance (189k points)
0 votes
1 answer 14 views
0 votes
1 answer 13 views
0 votes
1 answer 16 views
16 views asked Nov 10, 2020 in Technology by JackTerrance (189k points)
0 votes
1 answer 12 views
0 votes
1 answer 11 views
11 views asked Nov 10, 2020 in Technology by JackTerrance (189k points)
0 votes
1 answer 11 views
0 votes
1 answer 28 views
0 votes
1 answer 10 views
0 votes
1 answer 13 views
0 votes
1 answer 10 views
0 votes
1 answer 171 views
0 votes
1 answer 10 views
10 views asked Nov 10, 2020 in Technology by JackTerrance (189k points)
0 votes
1 answer 14 views
0 votes
1 answer 12 views
12 views asked Nov 10, 2020 in Technology by JackTerrance (189k points)
0 votes
1 answer 11 views
11 views asked Nov 10, 2020 in Technology by JackTerrance (189k points)
...