- (void)viewDidLoad {

    [super viewDidLoad];

    [NSThread detachNewThreadSelector:@selector(downloadImage) toTarget:self withObject:nil];

    

    

   }

-(void)downloadImage

{

    NSURL *url = [NSURL URLWithString:IMAGE_URL];

    NSData *data = [NSData dataWithContentsOfURL:url];

    UIImage *image = [UIImage imageWithData:data];

//    [self performSelectorOnMainThread:@selector(loadImage:) withObject:image waitUntilDone:NO];

    [self performSelector:@selector(loadImage:) onThread:[NSThread mainThread] withObject:image waitUntilDone:NO];

//    [self.imageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:NO];

    NSLog(@"1111");

    

}

-(void)loadImage:(id)obj

{

    self.imageView.image = obj;

}

 

//NSOperation线程间通信

 NSOperationQueue *queue = [[NSOperationQueue alloc]init];

    [queue addOperationWithBlock:^{

        NSURL *url = [NSURL URLWithString:IMAGE_URL];

        NSData *data = [NSData dataWithContentsOfURL:url];

        UIImage *image = [UIImage imageWithData:data];

        NSLog(@"--%@--",[NSThread currentThread]);

        [[NSOperationQueue mainQueue]addOperationWithBlock:^{

 

            self.imageView.image = image;

        }];

    }];