• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: code example on NSThread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: code example on NSThread


  • Subject: Re: code example on NSThread
  • From: Ondra Cada <email@hidden>
  • Date: Mon, 29 Jul 2002 14:47:08 +0200

On Monday, July 29, 2002, at 11:53 , Chong Hiu Pun wrote:

May you some me some example on how to use NSThread?Thanks!

#import <Foundation/Foundation.h>

@interface Threader:NSObject
-(void)entryPoint:o;
@end
@implementation Threader
-(void)entryPoint:o {
id p=[NSAutoreleasePool new];
NSString *myname=[o objectAtIndex:0];
int delay=[[o objectAtIndex:1] intValue];
for (;;) {
NSLog(@"%@ again",myname);
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:delay]];
}
[p release]; // not that it would be ever called
}
@end

void main() {
id p=[NSAutoreleasePool new];
id oo=[Threader new];
[NSThread detachNewThreadSelector:@selector(entryPoint:) toTarget:oo withObject:[NSArray arrayWithObjects:@"Second",@"1",nil]];
[NSThread detachNewThreadSelector:@selector(entryPoint:) toTarget:oo withObject:[NSArray arrayWithObjects:@"Three",@"3",nil]];
for (;;) {
NSLog(@"Press ^C to kill them all!");
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:4]];
}
[p release]; // not that it would be ever called
}
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: 
 >code example on NSThread (From: "Chong Hiu Pun" <email@hidden>)

  • Prev by Date: GraphPaper troubles
  • Next by Date: Re: Dereferencing a pointer in ObjC?
  • Previous by thread: Re: code example on NSThread
  • Next by thread: GraphPaper troubles
  • Index(es):
    • Date
    • Thread