lock
ロックが使用中ならスレッドを停止させます
解説
ロックが使用中ならスレッドを停止させます。
使用中でなければロックを使用中にします。
返り値
( void )
なし
引数
フレームワーク
Foundation
クラス
NSLocking
Instance Methods
使用可能
10.0
参照
例文
#import "Controller.h" @implementation Controller - (IBAction)pushButton:(id)sender { theLock = [[NSLock alloc] init]; [NSApplication detachDrawingThread:@selector(action:) toTarget:self withObject:@"thread1"]; [NSApplication detachDrawingThread:@selector(action:) toTarget:self withObject:@"thread2"]; } //スレッド -(void)action:(id)arg { int i; NSAutoreleasePool *pool = [NSAutoreleasePool new]; [theLock lock];//ロック for (i=1;i<2000;i++) { NSLog([NSString stringWithFormat:@"%@ %d",arg,i]); } [theLock unlock];//ロック解除 [pool release]; [NSThread exit]; } @end