Nsthread specific use: Direct inheritance NSObject
nsthread:.Pros: Nsthread is lightweight and easy to useCons: You need to manage your thread's lifecycle and thread synchronization. Thread synchronization has a certain overhead in locking data 1. Properties@property (ReadOnly, retain) nsmutabledictionary *threaddictionary; //Threading Dictionary @property double threadpriority; //Thread Priority @property nsqualityofservice qualityofservice; //Quality of service @property (copy) nsstring *name; //thread name @property Nsuinteger stackSize; //Stack size @property (readonly) BOOL ismainthread; //is the main thread@property (readonly, getter=isexecuting) BOOL executing; //Whether the thread is executing @property (readonly, getter=isfinished) BOOL finished; //Thread execution complete @property (readonly, getter=iscancelled) BOOL cancelled; //Whether the thread is canceled 2. Notice
※ will be a multi-threaded notification
foundation_export NSString * Const nswillbecomemultithreadednotification;
※ has become a single-threaded notificationfoundation_export NSString * Const nsdidbecomesinglethreadednotification;
※ notification that the thread will exitfoundation_export NSString * Const nsthreadwillexitnotification; 3. Main methods※ Current Thread+ (Nsthread *) CurrentThread;※ Create a thread's class method and add an execution event
+ (void) Detachnewthreadselector: (SEL) selector totarget: (ID) target withobject: (id) argument;
※ Whether it is multi-threading
+ (BOOL) ismultithreaded;
※ Timed Sleep
+ (void) Sleepuntildate: (NSDate *) date;
※ Sleep Time
+ (void) Sleepfortimeinterval: (Nstimeinterval) ti;
※ Exit Thread
+ (void) exit;
※ Thread Priority
+ (double) threadpriority;
※ Set Thread priority
+ (BOOL) SetThreadPriority: (double) p;
※ Displays the current stack contents (returns an array of the addresses that the thread occupies in the stack)
+ (Nsarray *) callstackreturnaddresses;
※ Return the symbol of the stack space
+ (Nsarray *) Callstacksymbols;
※ is the main thread
+ (BOOL) ismainthread;
※ Create an instance method of the thread and add an execution event
-(Instancetype) Initwithtarget: (ID) Target selector: (SEL) Selector object: (id) argument;
※ Cancel Thread
-(void) cancel;
※ Start Thread
-(void) start;
※ Thread body to execute the method: Thread Body method
-(void) main;
4, Category: @interface nsobject (nsthreadperformadditions)
※ Call the main thread to update the UI
-(void) Performselectoronmainthread: (SEL) Aselector withobject: (ID) arg waituntildone: (BOOL) Wait modes: (Nsarray *) Array
※ Calling the main thread
-(void) Performselectoronmainthread: (SEL) Aselector withobject: (ID) arg waituntildone: (BOOL) wait;
※ Call the specified thread to update the data
-(void) Performselector: (SEL) aselector onthread: (Nsthread *) THR Withobject: (ID) arg waituntildone: (BOOL) wait modes: ( Nsarray *) array;
※ Call the specified thread
-(void) Performselector: (SEL) aselector onthread: (Nsthread *) THR Withobject: (ID) arg waituntildone: (BOOL) wait;
※ threads are called in the background
-(void) Performselectorinbackground: (SEL) Aselector withobject: (ID) arg;
IOS: Multithreaded Nsthread for detailed use