四、线程管理————NSThread

1、创建新线程的三种方式,例如:

NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(demo:) object:nil];
[thread start];
[NSThread detachNewThreadSelector:@selector(demo:) toTarget:self withObject:nil];
    [self performSelectorInBackground:@selector(demo:) withObject:nil]; 准确的说此方法是NSObject的

2、NSThread在调试中的使用

    ·    获得线程的属性:name,stackSize,threadPriority

    ·    管理线程的类方法:start、exit、sleep

    ·    获得当前线程和主线程:   [NSThread currentThread]  、[NSThread mainThread];

posted @ 2016-03-14 01:23  独孤求傲  阅读(123)  评论(0编辑  收藏  举报