效果如下:
ViewController.h
#import <UIKit/UIKit.h> @interface ViewController : UITableViewController
@property (copy, nonatomic) NSArray *arrSampleName; - (instancetype)initWithSampleNameArray:(NSArray *)arrSampleName; @end
ViewController.m
#import "ViewController.h"
#import "FirstSampleViewController.h"
#import "SecondSampleViewController.h" @interface ViewController ()
- (void)layoutUI;
@end @implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad]; [self layoutUI];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} - (instancetype)initWithSampleNameArray:(NSArray *)arrSampleName {
if (self = [super initWithStyle:UITableViewStyleGrouped]) {
self.navigationItem.title = @"多线程开发之二 NSOperation";
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回首页" style:UIBarButtonItemStylePlain target:nil action:nil]; _arrSampleName = arrSampleName;
}
return self;
} - (void)layoutUI {
} #pragma mark - UITableViewController相关方法重写
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 0.1;
} - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return ;
} - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [_arrSampleName count];
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.textLabel.text = _arrSampleName[indexPath.row];
return cell;
} - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.row) {
case : {
FirstSampleViewController *firstSampleVC = [FirstSampleViewController new];
[self.navigationController pushViewController:firstSampleVC animated:YES];
break;
}
case : {
SecondSampleViewController *secondSampleVC = [SecondSampleViewController new];
[self.navigationController pushViewController:secondSampleVC animated:YES];
break;
}
default:
break;
}
} @end
UIImage+RescaleImage.h
#import <UIKit/UIKit.h> @interface UIImage (RescaleImage)
/**
* 根据宽高大小,获取对应的缩放图片
*
* @param size 宽高大小
*
* @return 对应的缩放图片
*/
- (UIImage *)rescaleImageToSize:(CGSize)size; @end
UIImage+RescaleImage.m
#import "UIImage+RescaleImage.h" @implementation UIImage (RescaleImage) - (UIImage *)rescaleImageToSize:(CGSize)size {
CGRect rect = CGRectMake(0.0, 0.0, size.width, size.height); UIGraphicsBeginImageContext(rect.size);
[self drawInRect:rect];
UIImage *imgScale = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext(); return imgScale;
} @end
Common.h
#import <Foundation/Foundation.h> @interface Common : NSObject
+ (NSURL *)randomImageURL; @end
Common.m
#import "Common.h" @implementation Common + (NSURL *)randomImageURL {
NSUInteger randomVal = (arc4random() % ) + ; //1-20的随机数
NSString *randomValStr = [NSString stringWithFormat:@"%lu", (unsigned long)randomVal];
if (randomVal < ) {
randomValStr = [@"" stringByAppendingString:randomValStr];
} NSString *imageURLStr = [NSString stringWithFormat:@"http://images.apple.com/v/watch/e/apple-watch/images/collection_%@_large.jpg", randomValStr];
return [NSURL URLWithString:imageURLStr];
} @end
FirstSampleViewController.h
#import <UIKit/UIKit.h> @interface FirstSampleViewController : UIViewController
@property (assign, nonatomic) CGSize rescaleImageSize; @property (strong, nonatomic) IBOutlet UIImageView *imgV;
@property (strong, nonatomic) IBOutlet UIButton *btnLoadImage; @end
FirstSampleViewController.m
#import "FirstSampleViewController.h"
#import "UIImage+RescaleImage.h"
#import "Common.h" @interface FirstSampleViewController ()
- (void)layoutUI;
- (void)updateImage:(NSData *)imageData;
- (void)loadImageFromNetwork;
@end @implementation FirstSampleViewController - (void)viewDidLoad {
[super viewDidLoad]; [self layoutUI];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} - (void)dealloc {
_imgV.image = nil;
} - (void)layoutUI {
CGFloat width = [[UIScreen mainScreen] bounds].size.width; //bounds 返回整个屏幕大小;applicationFrame 返回去除状态栏后的屏幕大小
CGFloat height = width * 438.0 / 366.0;
const CGFloat percentVal = 3.0 / 4.0; //以屏幕宽度的3/4比例显示
_rescaleImageSize = CGSizeMake(width * percentVal, height * percentVal); //NSString *path = [[NSBundle mainBundle] pathForResource:@"PictureNo@2x" ofType:@"png"];
//_imgV.image = [UIImage imageWithContentsOfFile:path]; _btnLoadImage.tintColor = [UIColor darkGrayColor];
_btnLoadImage.layer.masksToBounds = YES;
_btnLoadImage.layer.cornerRadius = 10.0;
_btnLoadImage.layer.borderColor = [UIColor grayColor].CGColor;
_btnLoadImage.layer.borderWidth = 1.0;
} - (void)updateImage:(NSData *)imageData {
UIImage *img = [UIImage imageWithData:imageData];
_imgV.image = [img rescaleImageToSize:_rescaleImageSize];
} - (void)loadImageFromNetwork {
NSURL *url = [Common randomImageURL];
NSData *data = [NSData dataWithContentsOfURL:url]; //mainQueue 是 UI 主线程,调用主线程队列的方法进行操作
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self updateImage:data];
}];
} - (IBAction)loadImage:(id)sender {
//方法一:使用 NSInvocationOperation
// NSInvocationOperation *invocationOperation = [[NSInvocationOperation alloc]
// initWithTarget:self
// selector:@selector(loadImageFromNetwork)
// object:nil];
// NSOperationQueue *operationQueue = [NSOperationQueue new]; //操作队列
// [operationQueue addOperation:invocationOperation]; //方法二:使用 NSBlockOperation
NSBlockOperation *blockOperation = [NSBlockOperation blockOperationWithBlock:^{
[self loadImageFromNetwork];
}];
[blockOperation addExecutionBlock:^{ //还可以为 blockOperation 添加代码块;多个代码块会被分到多个线程去执行,存在两个代码块被分配到同一个线程执行的情况
NSLog(@"代码块");
}];
[blockOperation addExecutionBlock:[blockOperation executionBlocks][]]; //这里可以调用他的 executionBlocks 获取到添加的代码块数组;上面打印的内容「代码块」会被执行两次 [blockOperation setCompletionBlock:^{
NSLog(@"所有代码块操作执行完毕后(无论已取消还是已完成),做一些事情,只执行一次");
}]; //[blockOperation start]; //使用 start 方法,则此操作在主线程中执行;一般不这样操作,而是添加到操作队列中
NSOperationQueue *operationQueue = [NSOperationQueue new]; //操作队列
[operationQueue addOperation:blockOperation]; //添加到操作队列,这时队列会开启一个线程去执行此操作;一个线程可以执行多个操作 //方法三:直接使用 NSOperationQueue
// NSOperationQueue *operationQueue = [NSOperationQueue new]; //操作队列
// [operationQueue addOperationWithBlock:^{
// [self loadImageFromNetwork];
// }];
} @end
FirstSampleViewController.xib
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="FirstSampleViewController">
<connections>
<outlet property="btnLoadImage" destination="sLs-f1-Gzc" id="kX8-J0-v0V"/>
<outlet property="imgV" destination="4Qp-uk-KAb" id="RM3-Ha-glh"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PictureNo.png" translatesAutoresizingMaskIntoConstraints="NO" id="4Qp-uk-KAb">
<rect key="frame" x="205" y="225" width="190" height="150"/>
<constraints>
<constraint firstAttribute="height" constant="150" id="SIp-Wd-idU"/>
<constraint firstAttribute="height" constant="150" id="VwM-i1-atB"/>
<constraint firstAttribute="width" constant="190" id="mUh-Bu-tUd"/>
<constraint firstAttribute="width" constant="190" id="mdJ-1c-QFa"/>
<constraint firstAttribute="width" constant="190" id="sVS-bU-Ty9"/>
<constraint firstAttribute="height" constant="150" id="uMG-oN-J56"/>
<constraint firstAttribute="height" constant="150" id="vws-Qw-UrB"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="SIp-Wd-idU"/>
<exclude reference="VwM-i1-atB"/>
<exclude reference="mUh-Bu-tUd"/>
<exclude reference="mdJ-1c-QFa"/>
<exclude reference="sVS-bU-Ty9"/>
<exclude reference="uMG-oN-J56"/>
<exclude reference="vws-Qw-UrB"/>
</mask>
</variation>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="sLs-f1-Gzc">
<rect key="frame" x="230" y="500" width="140" height="50"/>
<constraints>
<constraint firstAttribute="width" constant="140" id="1jv-9K-mdH"/>
<constraint firstAttribute="height" constant="50" id="Q2w-vR-9ac"/>
</constraints>
<state key="normal" title="加载网络图片">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="loadImage:" destination="-1" eventType="touchUpInside" id="fdy-Ln-5oS"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="4Qp-uk-KAb" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="205" id="2a2-mS-WFa"/>
<constraint firstItem="sLs-f1-Gzc" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="ES4-wl-RBz"/>
<constraint firstItem="4Qp-uk-KAb" firstAttribute="centerY" secondItem="i5M-Pr-FkT" secondAttribute="centerY" id="MUJ-WA-sUf"/>
<constraint firstItem="4Qp-uk-KAb" firstAttribute="centerX" secondItem="sLs-f1-Gzc" secondAttribute="centerX" id="Q8a-1k-DzJ"/>
<constraint firstAttribute="bottom" secondItem="4Qp-uk-KAb" secondAttribute="bottom" constant="71" id="V0a-9y-Dwa"/>
<constraint firstAttribute="bottom" secondItem="sLs-f1-Gzc" secondAttribute="bottom" constant="50" id="VMG-CV-eeq"/>
<constraint firstItem="4Qp-uk-KAb" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" constant="-71" id="gqW-Wq-4Zv"/>
<constraint firstItem="sLs-f1-Gzc" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="kNf-6d-EJ8"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="2a2-mS-WFa"/>
<exclude reference="V0a-9y-Dwa"/>
<exclude reference="gqW-Wq-4Zv"/>
<exclude reference="ES4-wl-RBz"/>
</mask>
</variation>
</view>
</objects>
<resources>
<image name="PictureNo.png" width="190" height="150"/>
</resources>
</document>
SecondSampleViewController.h
#import <UIKit/UIKit.h> @interface SecondSampleViewController : UIViewController
@property (assign, nonatomic) CGSize rescaleImageSize;
@property (strong, nonatomic) NSMutableArray *mArrImageView; @property (strong, nonatomic) IBOutlet UIButton *btnLoadImage; @end
SecondSampleViewController.m
#import "SecondSampleViewController.h"
#import "UIImage+RescaleImage.h"
#import "Common.h" #define kRowCount 4
#define kColumnCount 3
#define kCellSpacing 10.0 @interface SecondSampleViewController ()
- (void)layoutUI;
- (void)updateImage:(NSData *)imageData withImageIndex:(NSInteger)imageIndex;
-(NSData *)requestData:(NSInteger)imageIndex;
- (void)loadImageFromNetwork:(NSInteger)imageIndex;
@end @implementation SecondSampleViewController - (void)viewDidLoad {
[super viewDidLoad]; [self layoutUI];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} - (void)dealloc {
_mArrImageView = nil;
} - (void)layoutUI {
CGFloat width = ([[UIScreen mainScreen] bounds].size.width - ((kColumnCount + ) * kCellSpacing)) / kColumnCount;
_rescaleImageSize = CGSizeMake(width, width); CGFloat heightOfStatusAndNav = 20.0 + 44.0;
NSString *path = [[NSBundle mainBundle] pathForResource:@"PictureNo@2x" ofType:@"png"];
UIImage *img = [UIImage imageWithContentsOfFile:path];
_mArrImageView = [NSMutableArray arrayWithCapacity:kRowCount * kColumnCount];
//初始化多个图片视图
for (NSUInteger i=; i<kRowCount; i++) {
for (NSUInteger j=; j<kColumnCount; j++) {
UIImageView *imgV = [[UIImageView alloc] initWithFrame:
CGRectMake(_rescaleImageSize.width * j + kCellSpacing * (j+),
_rescaleImageSize.height * i + kCellSpacing * (i+) + heightOfStatusAndNav,
_rescaleImageSize.width,
_rescaleImageSize.height)];
imgV.image = img;
[self.view addSubview:imgV];
[_mArrImageView addObject:imgV];
}
} _btnLoadImage.tintColor = [UIColor darkGrayColor];
_btnLoadImage.layer.masksToBounds = YES;
_btnLoadImage.layer.cornerRadius = 10.0;
_btnLoadImage.layer.borderColor = [UIColor grayColor].CGColor;
_btnLoadImage.layer.borderWidth = 1.0;
} - (void)updateImage:(NSData *)imageData withImageIndex:(NSInteger)imageIndex {
UIImage *img = [UIImage imageWithData:imageData];
UIImageView *imgVCurrent = _mArrImageView[imageIndex];
imgVCurrent.image = [img rescaleImageToSize:_rescaleImageSize];
} -(NSData *)requestData:(NSInteger)imageIndex {
//对于多线程操作,建议把线程操作放到 @autoreleasepool 中
@autoreleasepool {
NSURL *url = [Common randomImageURL];
NSData *data = [NSData dataWithContentsOfURL:url];
return data;
}
} - (void)loadImageFromNetwork:(NSInteger)imageIndex {
/*
对比之前 NSThread 加载图片,你会发现核心代码简化了不少,有两点值得提的:
(1)使用 NSBlockOperation 方法,所有的操作不必单独定义方法,同时解决了只能传递一个参数的问题。类似的操作,例如:调用主线程队列的 addOperationWithBlock: 方法进行 UI 更新,不用再定义一个参数实体类来进行参数传递(之前必须定义一个 KMImageData 解决只能传递一个参数的问题)。
(2)使用 NSOperation 进行多线程开发可以设置最大并发操作数,有效的对操作进行控制(如 Demo 的代码设置最大并发操作数为5,则图片最多是五个一次加载的)。
*/
NSLog(@"Current thread:%@", [NSThread currentThread]); //mainQueue 是 UI 主线程,调用主线程队列的方法进行操作
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self updateImage:[self requestData:imageIndex] withImageIndex:imageIndex];
}];
} - (IBAction)loadImage:(id)sender {
NSOperationQueue *operationQueue = [NSOperationQueue new];
operationQueue.maxConcurrentOperationCount = ; //设置最大并发操作数 NSUInteger len = kRowCount * kColumnCount;
NSBlockOperation *lastBlockOperation = [NSBlockOperation blockOperationWithBlock:^{
[self loadImageFromNetwork:len - ];
}]; for (NSUInteger i=; i<len - ; i++) {
NSBlockOperation *blockOperation = [NSBlockOperation blockOperationWithBlock:^{
[self loadImageFromNetwork:i];
}]; //实现控制「操作执行顺序」,例如:控制最后一个操作第一个执行,这里设置操作的依赖关系为:最后一张图片加载操作完成后才执行
//PS:注意请勿进行循环依赖,否则循环依赖相关的操作是不会被执行的
//这里添加依赖关系;其相对应的移除方法:- (void)removeDependency:(NSOperation *)op;
[blockOperation addDependency:lastBlockOperation]; //另外添加操作对象实例数组的方法:- (void)addOperations:(NSArray *)ops waitUntilFinished:(BOOL)wait;
[operationQueue addOperation:blockOperation];
} [operationQueue addOperation:lastBlockOperation]; /*
lastBlockOperation.queuePriority = NSOperationQueuePriorityVeryHigh; //在某个操作队列中的队列优先级;这样可以提高他被优先加载的机率,但是他也未必就第一个加载;所以要实现控制「操作执行顺序」,就得用设置操作的依赖关系的方式 typedef enum : NSInteger {
NSOperationQueuePriorityVeryLow = -8,
NSOperationQueuePriorityLow = -4,
NSOperationQueuePriorityNormal = 0,
NSOperationQueuePriorityHigh = 4,
NSOperationQueuePriorityVeryHigh = 8
} NSOperationQueuePriority;
*/
} @end
SecondSampleViewController.xib
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="SecondSampleViewController">
<connections>
<outlet property="btnLoadImage" destination="F5h-ZI-gGL" id="I40-e2-bAa"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="F5h-ZI-gGL">
<rect key="frame" x="230" y="530" width="140" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="HWd-Xc-Wk7"/>
<constraint firstAttribute="width" constant="140" id="vrH-qE-PNK"/>
</constraints>
<state key="normal" title="加载网络图片">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="loadImage:" destination="-1" eventType="touchUpInside" id="Hgw-q8-lHy"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="F5h-ZI-gGL" secondAttribute="bottom" constant="20" id="jPY-fY-9XJ"/>
<constraint firstAttribute="centerX" secondItem="F5h-ZI-gGL" secondAttribute="centerX" id="rH1-sV-pST"/>
</constraints>
</view>
</objects>
</document>
AppDelegate.h
#import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UINavigationController *navigationController; @end
AppDelegate.m
#import "AppDelegate.h"
#import "ViewController.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
ViewController *viewController = [[ViewController alloc] initWithSampleNameArray:@[@"请求单张网络图片(解决线程阻塞)", @"请求多张网络图片(多个线程并发)"]];
_navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
_window.rootViewController = _navigationController;
//[_window addSubview:_navigationController.view]; //当_window.rootViewController关联时,这一句可有可无
[_window makeKeyAndVisible];
return YES;
} - (void)applicationWillResignActive:(UIApplication *)application {
} - (void)applicationDidEnterBackground:(UIApplication *)application {
} - (void)applicationWillEnterForeground:(UIApplication *)application {
} - (void)applicationDidBecomeActive:(UIApplication *)application {
} - (void)applicationWillTerminate:(UIApplication *)application {
} @end
输出结果:
-- ::36.878 NSOperationDemo[:] 代码块
-- ::36.878 NSOperationDemo[:] 代码块
-- ::37.366 NSOperationDemo[:] 所有代码块操作执行完毕后(无论已取消还是已完成),做一些事情,只执行一次 -- ::42.505 NSOperationDemo[:] Current thread:<NSThread: 0x7fbd1bd335b0>{number = , name = (null)}
-- ::42.506 NSOperationDemo[:] Current thread:<NSThread: 0x7fbd1be0ad90>{number = , name = (null)}
-- ::42.507 NSOperationDemo[:] Current thread:<NSThread: 0x7fbd1e047390>{number = , name = (null)}
-- ::42.507 NSOperationDemo[:] Current thread:<NSThread: 0x7fbd1e047390>{number = , name = (null)}
-- ::42.507 NSOperationDemo[:] Current thread:<NSThread: 0x7fbd1be0ad90>{number = , name = (null)}
-- ::42.507 NSOperationDemo[:] Current thread:<NSThread: 0x7fbd1be07c70>{number = , name = (null)}
-- ::42.508 NSOperationDemo[:] Current thread:<NSThread: 0x7fbd1be0ad90>{number = , name = (null)}
-- ::42.508 NSOperationDemo[:] Current thread:<NSThread: 0x7fbd1be07c70>{number = , name = (null)}
-- ::42.508 NSOperationDemo[:] Current thread:<NSThread: 0x7fbd1be0ad90>{number = , name = (null)}
-- ::42.508 NSOperationDemo[:] Current thread:<NSThread: 0x7fbd1e047390>{number = , name = (null)}
-- ::42.508 NSOperationDemo[:] Current thread:<NSThread: 0x7fbd1e0335f0>{number = , name = (null)}
-- ::42.508 NSOperationDemo[:] Current thread:<NSThread: 0x7fbd1be0ad90>{number = , name = (null)}