in Technology by

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

1 Answer

0 votes
by

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.”

Related questions

0 votes
    As I understand it, anything created with an alloc, new, or copy needs to be manually released. For ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    Which feature of java 8 enables us to create a work stealing thread pool using all available processors at ... Miscellaneous of Java Select the correct answer from above options...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    Does a parameter have its own drop-down list?...
asked Oct 30, 2020 in Technology by JackTerrance
0 votes
    The object that looks to the thread that creates it is _______________ (a) Window (b) Worker (c) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 22, 2021 in Education by JackTerrance
0 votes
    Is there any reason to keep time series data in its own database, separate from other tables or is ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 10, 2022 in Education by JackTerrance
0 votes
    Which of the following is advantage of using JDBC connection pool? (a) Slow performance (b) Using more memory (c) ... & JDBC of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
0 votes
    Which of the following is advantage of using JDBC connection pool? (a) Slow performance (b) Using more ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    If a robot can alter its own trajectory in response to external conditions, it is considered to be __________ (a) ... open loop (d) non-servo Please answer the above question....
asked Oct 22, 2022 in Education by JackTerrance
0 votes
    If a robot can alter its own trajectory in response to external conditions, it is considered to be __________ (a) ... open loop (d) non-servo Please answer the above question....
asked Oct 2, 2022 in Education by JackTerrance
0 votes
    State whether the following statement are true or false with reasons. Sovereignty means State has the freedom to take its own decision. Please answer the above question....
asked Aug 4, 2022 in Education by JackTerrance
0 votes
    According to Kafka Documentation Connector configurations are simple key-value mappings. For standalone mode these are ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    According to Kafka Documentation Connector configurations are simple key-value mappings. For standalone mode these are ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    The question is: after am raising an exception, can I stop it to propagate from it's own constructor ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
...