/*************************************************************** * * MTTest * ***************************************************************/ #import #import id testLockB; @interface DummyClass: NSObject - (void) run: (id) ignored; - (void) becomeThreaded: (id) ignored; @end @implementation DummyClass - (void) becomeThreaded: (id) ignored { NSLog (@"Becoming multithreaded!!"); testLockB = [GSLazyLock new]; NSLog (@"Creating B (while becoming multithreaded!) type: %@", [testLockB class]); } - (void) run: (id) ignored { NSLog (@"Run in different thread!!"); } @end int main (void) { id arp = [[NSAutoreleasePool alloc] init]; id testLockA = [GSLazyLock new]; id test = [DummyClass new]; NSLog (@"Creating A (before becoming multithreaded) type: %@", [testLockA class]); [[NSNotificationCenter defaultCenter] addObserver: test selector: @selector (becomeThreaded:) name: NSWillBecomeMultiThreadedNotification object: nil]; [NSThread detachNewThreadSelector: @selector (run:) toTarget: [DummyClass new] withObject: nil]; NSLog (@"Class of A after becoming multithreaded: %@", [testLockA class]); NSLog (@"Class of B after becoming multithreaded: %@", [testLockB class]); [test release]; [testLockA release]; [testLockB release]; [arp release]; return 0; }