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