isExecuting:正在執行->只讀 isFinished :執行完了->只讀 isCancelled:已經取消->能夠手動干預,調用cancel()方法 - 只是設置線程狀態,並非真正的中止當前線程
將操做添加到線程中並直接啓動spa
+ (void)detachNewThreadSelector:(SEL)selector toTarget:(id)target withObject:(id)argument;
建立一個線程對象,而後調用start方法啓動線程.net
- (instancetype)initWithTarget:(id)target selector:(SEL)sel object:(id)arg;
-(void)start;
-(void)cancel;
######3.3結束當前線程,寫在線程內部線程
能夠結合cancel方法進行exitcode
+(void)exit;
+ (void)sleepUntilDate:(NSDate *)date; //>>>睡眠到某個日時後,取消睡眠 + (void)sleepForTimeInterval:(NSTimeInterval)ti; //>>>睡眠多長時間
線程優先級範圍:0-1orm
每一個線程默認優先級爲0.5對象
優先級越大,只能說明被執行的概率越大,可是執行順序仍是隨機的blog
+ (BOOL)setThreadPriority:(double)p;
- (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg;
- (void)performSelector:(SEL)aSelector onThread:(NSThread *)thr withObject:(id)arg waitUntilDone:(BOOL)wait //modes:(NSArray<NSString *> *)array;
- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait //modes:(NSArray<NSString *> *)array;
===================================================get
其它線程方式:it