国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 系統(tǒng) > iOS > 正文

iOS中NSThread線程

2019-11-06 10:00:25
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

#import "NSThreadViewController.h"

@interface NSThreadViewController ()

@end

@implementation NSThreadViewController

- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. }

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

[self threadDemo];

}

-(void)threadDemo{

NSThread * thread = [[NSThread alloc] initWithTarget:self selector:@selector(demo:) object:@"ddd"];// detach 分離 出來(lái)一個(gè)子線程[NSThread detachNewThreadSelector:@selector(demo:) toTarget:self withObject:@"tttt"];[thread start];//子線程 所有繼承NSObject的都可以使用[self performSelectorInBackground:@selector(demo:) withObject:@"ddd"];//在指定線程上進(jìn)行操作[self performSelector:@selector(demo:) onThread:[NSThread mainThread] withObject:@"4444" waitUntilDone:NO];

}

-(void)demo:(id)obj {

//交替執(zhí)行線程for ( int i = 0; i< 2; i++) { NSLog(@"%@%@",[NSThread currentThread],obj);}

}

@end


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 遂宁市| 柘荣县| 上犹县| 买车| 秭归县| 遂昌县| 镇雄县| 正蓝旗| 五指山市| 宜川县| 沿河| 东阿县| 衢州市| 莎车县| 台安县| 吉隆县| 安岳县| 保德县| 岑溪市| 定远县| 正定县| 东兰县| 布尔津县| 麻江县| 绥化市| 崇义县| 五莲县| 荔波县| 隆德县| 神池县| 阳城县| 赣榆县| 搜索| 尉犁县| 古丈县| 措美县| 金湖县| 江安县| 女性| 秦皇岛市| 泌阳县|