<h3>First way (NSOperationQueue):</h3><pre style="background-color: #f0f0f0; border: 1px dashed rgb(204, 204, 204); font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; width: 646.4666748046875px;"> NSOperationQueue *q = [[NSOperationQueue alloc] init];
</pre><h3>Second way:</h3><pre style="background-color: #f0f0f0; border: 1px dashed rgb(204, 204, 204); font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; width: 646.4666748046875px;">
[q addOperationWithBlock:^{
//Do Things
}];
[q release]; [self performSelectorInBackground:@selector(func1:) withObject:nil];
</pre>
<h3>Third way (Schedule with timer):</h3><pre style="background-color: #f0f0f0; border: 1px dashed rgb(204, 204, 204); font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; width: 646.4666748046875px;"> [NSTimer scheduledTimerWithTimeInterval:1.0 target:self
</pre>
selector:@selector( methodName: )
userInfo:parameter repeats:NO];
Source
<h3>Notes</h3>If you want to run code in the main thread from other thread (like GUI updates or another…) see
Run code in main thread from other
read