Multi-threaded help
Multi-threaded help
- Subject: Multi-threaded help
- From: Steve Walter <email@hidden>
- Date: Wed, 7 Mar 2007 22:48:17 +0000
Hi everyone.
I am trying this new game: multi-threaded programming.
After I went through whole apple's document, I tried to produce some
result . However, I failed.
I wrote an application , whose function is: at first it creates a
thread, then it uses a nstimer to wake the thread and order the
thread to printf a statement to the console every second.
Really need someone help me to clarify my following code:
#import "AppControl.h"
@implementation AppControl
- (IBAction)go:(id)sender
{
eventTimer = [[NSTimer timerWithTimeInterval:1.0
target:self
selector:@selector(fireTimer:)
userInfo:nil
repeats:YES] retain];
[NSThread detachNewThreadSelector:@selector(runLoop:)
toTarget:self
withObject:nil];
[evenTimer fire];
}
-(void)runLoop:(id) sender{
NSAutoreleasePool * myPool;
myPool = [[NSAutoreleasePool alloc] init];
[[NSRunLoop currentRunLoop] addTimer:eventTimer
forMode:NSDefaultRunLoopMode];
[myPool release];
}
-(void) fireTimer:(id) sender{
printf("In the fire timer function\n");
}
@end
I am excepting to see something in the console. God is kidding me -
completely blank.
Really NEED YOUR HELP. THANK YOU IN ADVANCE.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden