zoukankan      html  css  js  c++  java
  • NSThread 多线程 三种方式

    //

    //  ZBMainViewController.m

    //  TestProject

    //

    //  Created by 张先森 on 14/12/5.

    //  Copyright (c) 2014年 zhibin. All rights reserved.

    //

    #import "ZBMainViewController.h"

    @interface ZBMainViewController ()

    @property(nonatomic,strong)CALayer *mylayer;

    @end

    @implementation ZBMainViewController

     bool isopen=NO;

    - (void)viewDidLoad {

        [super viewDidLoad];

        [self InitControls];

    }

    -(void)InitControls{

        NSThread *thread=[NSThread currentThread];

        NSLog(@"%@",thread);

        NSThread *mainthread=[NSThread mainThread];

        NSLog(@"%@",mainthread);

        

        

        NSThread *tempthread=[[NSThread alloc] initWithTarget:self selector:@selector(run:) object:@"线程1"];

        tempthread.name=@"thread1";

        

        [tempthread start];

        

        

        

        

        [NSThread detachNewThreadSelector:@selector(run:) toTarget:self withObject:@"线程2"];

        

        

        

        

        [self performSelectorInBackground:@selector(run:) withObject:@"线程3"];

    }

    -(void)run:(NSString *)str{

        NSLog(@"%@",str);

    }

    @end

  • 相关阅读:
    wso2 CEP集成storm实验
    mybatis的decimal精度缺失
    计算时间偏移量小工具
    Blob写入文件
    java父子进程通信
    log4j2配置MDC分线程写日志
    结构体
    局部变量与全局变量
    ARM漏洞
    ARM承认芯片漏洞:披露修复细节
  • 原文地址:https://www.cnblogs.com/zhibin/p/4152275.html
Copyright © 2011-2022 走看看