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);
    
     
  • 相关阅读:
    js动态增加html页面元素
    sql(转自http://www.imooc.com/article/2325)
    正则表达式(转自https://segmentfault.com/a/1190000000699097)
    ssh整合(http://blog.csdn.net/songanling/article/details/22454973)
    json(http://www.cnblogs.com/lanxuezaipiao/archive/2013/05/24/3096437.html)
    spring定时器设置(转自:http://my.oschina.net/LvSantorini/blog/520049)
    (转)MyEclipse自动生成Hibernate实体类, oracle篇
    互联网安全
    来做几道算术题
    py打包exe的那些事
  • 原文地址:https://www.cnblogs.com/ndyBlog/p/3958895.html
Copyright © 2011-2022 走看看