iOS multithreaded development small DEMO3, thread state

Source: Internet
Author: User

Created by DYF on 14-6-23.//Copyright (c) 2014 ___fullusername___. All rights reserved.//#import "DYFViewController.h" @interface Dyfviewcontroller () @property (nonatomic, Strong) Nsthread *thread; @end @implementation dyfviewcontroller-(void) viewdidload{[Super viewdidload];//do any additional set        Up after loading the view, typically from a nib.    Self.thread = [[Nsthread alloc] initwithtarget:self selector: @selector (Test) object:@ "111"]; Self.thread.name = @ "1111111111";}    -(void) test {//NSLog (@ "startedtest------%@", [[Nsthread CurrentThread] name]);    Blocking state 2//NSDate *date = [NSDate datewithtimeintervalsincenow:5.0];//[Nsthread sleepuntildate:date];        Blocking state 1//[Nsthread sleepfortimeinterval:5.0];                for (int i = 0; i < 999; i++) {NSLog (@ "Test-----%d------%@", I, [[Nsthread CurrentThread] name]);        if (i = =) {[Nsthread exit]; }} NSLog (@ "endedtest------%@", [[Nsthread CurrenTThread] name]);} #warning Click 2 times the screen will appear ' nsinvalidargumentexception ', Reason: ' * * *-[nsthread start]: Attempt to start the thread again ', called dead Thread will error-(void) Touchesbegan: (Nsset *) touches withevent: (uievent *) event{//Open thread [Self.thread start];} @end

Summary: There are about 5 threads in the state

New ready to run block death

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.