-(void) delay1{ // deferred execution do not use sleep, bad: stuck to the current thread [nsthread Sleepfortimeinterval:3]; NSLog (@ "-----Download Picture-----");}
-(void) delay2{ // Once the delay task has been customized, the main current thread will not be jammed (which thread execution of the deferred task depends on where the current code is called) [ Self performselector: @selector (Download:) Withobject:@ "http://555.jpg" afterdelay: 3];}
- (void) delay3{//3 seconds back to the main thread execute code in block//dispatch_queue_t queue = Dispatch_get_main_queue ();//Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (3 * nsec_per_sec)), queue, ^{//NSLog (@ "------task------%@", [Nsthread CurrentThread]);// }); //automatically open a new thread after 3 seconds to execute the code in the block (that is, it will open a new thread for you to execute the code in the block after a period of time)dispatch_queue_t queue = Dispatch_get_global_queue (Dispatch_queue_priority_default,0); Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (3* nsec_per_sec)), queue, ^{NSLog (@"------Task------%@", [Nsthread CurrentThread]); });}
4. Common presentation methods and pros and cons in iOS