- (IBAction)action:(id)sender { int i=10000; NSString * data; dispatch_queue_t queue = dispatch_queue_create("com.wang.queue", NULL); while(i>0) { data = [[NSString alloc]initWithFormat:@"%i",i]; NSString * str = data; dispatch_async(queue, ^{{ [self print:str]; }}); i--; } } -(void) print:(NSString*)str { NSLog(@"%@",str); str = nil; }
解决方案