zoukankan      html  css  js  c++  java
  • ios多线程之NSThread头文件详解

    1、NSThread
    头文件中的相关方法
    //获取当前线程
     +(NSThread *)currentThread; 
    //创建线程后自动启动线程
    + (void)detachNewThreadSelector:(SEL)selector toTarget:(id)target withObject:(id)argument;
    //是否是多线程
    + (BOOL)isMultiThreaded;
    //线程字典
    - (NSMutableDictionary *)threadDictionary;
    //线程休眠到什么时间
    + (void)sleepUntilDate:(NSDate *)date;
    //线程休眠多久
    + (void)sleepForTimeInterval:(NSTimeInterval)ti;
    //退出线程
    + (void)exit;
    
    //线程优先级
    + (double)threadPriority;
    + (BOOL)setThreadPriority:(double)p;
    
    - (double)threadPriority NS_AVAILABLE(10_6, 4_0);
    - (void)setThreadPriority:(double)p NS_AVAILABLE(10_6, 4_0);
    
    //调用栈返回地址
    + (NSArray *)callStackReturnAddresses NS_AVAILABLE(10_5, 2_0);
    + (NSArray *)callStackSymbols NS_AVAILABLE(10_6, 4_0);
    
    //设置线程名字
    - (void)setName:(NSString *)n NS_AVAILABLE(10_5, 2_0);
    - (NSString *)name NS_AVAILABLE(10_5, 2_0);
    
    //获取栈的大小
    - (NSUInteger)stackSize NS_AVAILABLE(10_5, 2_0);
    - (void)setStackSize:(NSUInteger)s NS_AVAILABLE(10_5, 2_0);
    
    //是否是主线程
    - (BOOL)isMainThread NS_AVAILABLE(10_5, 2_0);
    + (BOOL)isMainThread NS_AVAILABLE(10_5, 2_0); // reports whether current thread is main
    + (NSThread *)mainThread NS_AVAILABLE(10_5, 2_0);
    
    - (id)init NS_AVAILABLE(10_5, 2_0);	// designated initializer
    - (id)initWithTarget:(id)target selector:(SEL)selector object:(id)argument NS_AVAILABLE(10_5, 2_0);
    
    //是否正在执行
    - (BOOL)isExecuting NS_AVAILABLE(10_5, 2_0);
    //是否执行完成
    - (BOOL)isFinished NS_AVAILABLE(10_5, 2_0);
    
    //是否取消线程
    - (BOOL)isCancelled NS_AVAILABLE(10_5, 2_0);
    - (void)cancel NS_AVAILABLE(10_5, 2_0);
    
    //线程启动
    - (void)start NS_AVAILABLE(10_5, 2_0);
    
    - (void)main NS_AVAILABLE(10_5, 2_0);	// thread body method
    
    @end
    
    //多线程通知
    FOUNDATION_EXPORT NSString * const NSWillBecomeMultiThreadedNotification;
    FOUNDATION_EXPORT NSString * const NSDidBecomeSingleThreadedNotification;
    FOUNDATION_EXPORT NSString * const NSThreadWillExitNotification;
    
    @interface NSObject (NSThreadPerformAdditions)
    
    //与主线程通信
    - (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait modes:(NSArray *)array;
    - (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait;
    	// equivalent to the first method with kCFRunLoopCommonModes
    
    //与其他子线程通信
    - (void)performSelector:(SEL)aSelector onThread:(NSThread *)thr withObject:(id)arg waitUntilDone:(BOOL)wait modes:(NSArray *)array NS_AVAILABLE(10_5, 2_0);
    - (void)performSelector:(SEL)aSelector onThread:(NSThread *)thr withObject:(id)arg waitUntilDone:(BOOL)wait NS_AVAILABLE(10_5, 2_0);
    	// equivalent to the first method with kCFRunLoopCommonModes
    
    
    //隐式创建并启动线程
    - (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg NS_AVAILABLE(10_5, 2_0);
    
     
  • 相关阅读:
    新手讲排序:希尔排序
    安装部署VMware vSphere 5.5文档 (6-6) 集群和vMotion
    安装部署VMware vSphere 5.5文档 (6-5) 安装配置vCenter
    同步VDP时间
    vdp配置
    python定义常量
    OpenStack Keystone V3 简介
    nginx + uswgi +django
    安装系统
    Standard NSD file
  • 原文地址:https://www.cnblogs.com/ndyBlog/p/3958895.html
Copyright © 2011-2022 走看看