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

  • 相关阅读:
    container宽度
    NO.14 两个div并排,左边为绝对宽度,右边为相对宽度
    CSS3旋转图片效果收集
    背景图片问题
    CSS动画
    前端比较有用的网址
    JS如何判断IE和火狐与Chrome浏览器
    JAVA多线程面试题目
    JAVA多线程之Semaphore
    阿里多线程笔试题
  • 原文地址:https://www.cnblogs.com/zhibin/p/4152275.html
Copyright © 2011-2022 走看看