gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thread question


From: Richard Frith-Macdonald
Subject: Re: Thread question
Date: Wed, 2 Mar 2011 06:21:12 +0000

On 1 Mar 2011, at 20:04, Banlu Kemiyatorn wrote:

> Hi, sorry, just delete a couple lines of code, was trying to get mail
> shorter, here's the complete code
> 
> #include <unistd.h>
> #import <Foundation/Foundation.h>
> @interface MyObj:NSObject
> @end
> 
> @implementation MyObj
> - (void) launch
> {
>      // id p = [NSAutoreleasePool new];
>       NSLog(@"x");
>       //[p release];
> }
> @end
> 
> int main (int argc, const char * argv[]) {
>       id p = [NSAutoreleasePool new];
> 
>       id obj = [MyObj new];
>       [NSThread detachNewThreadSelector:@selector(launch)
> toTarget:obj withObject:nil];
>       [NSThread detachNewThreadSelector:@selector(launch)
> toTarget:obj withObject:nil];
> 
> sleep(20);
> return 0;
> }
> 

OK ... that should build and run for you (and does for me) without trouble.
If it usually works, but fails, rarely, I guess there might be some race 
condition in gnustep-base (but from looking at the source I can't see how that 
could be).
If it fails consistently, I think there is something wrong with locking or 
threading on your machine.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]