|
From: | ramana rao |
Subject: | Fw: Code excerpt, running in OpenStep and failing in GNUstep! |
Date: | Thu, 1 Nov 2001 20:34:55 +0530 |
Hello GNUstepDiscussion group,
The given below code does run in OpenStep under NT and
Solaris, but is not running GNUstep/Solaris8.
The following is a simple just detaching two threads, it is
giving 'Uncaught exception NSLockException, reason: Thread attempted to
recursively loc" under GNUstep
Does anybody have any clue, we have ported applications
from Open Step to GNUstep, which use plenty of threads, and often they are
crashing giving stack traces in libthread.so
thanks for any help
Ramana Rao
*****************************Main***************************************
#import <Foundation/Foundation.h>
#import "threadParent.h" int main (int argc, const char
*argv[])
{ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; threadParent *tP; NSLock *theLock; tP = [[threadParent alloc] init]; [tP run]; theLock = [[NSLock alloc] init]; [theLock lock]; [theLock lock]; [pool release]; exit(0); // insure the process exit status is 0 } ************************************************************************************ ********************************threadParent.m*************************************
#import "threadParent.h"
@implementation threadParent
-init{ [super init]; return self; } -(void)run{ NSLog(@"Going to detach threads");
[NSThread detachNewThreadSelector:@selector(forThreadOne) toTarget:self withObject:nil]; [NSThread detachNewThreadSelector:@selector(forThreadTwo) toTarget:self withObject:nil]; NSLog(@"Detached the threads"); } -(void) forThreadOne{
NSAutoreleasePool *outerPool = [[NSAutoreleasePool alloc] init]; while(1){ NSAutoreleasePool *innerPool = [[NSAutoreleasePool alloc] init]; NSLog(@"From One"); [NSThread sleepUntilDate:[[NSDate date] addTimeInterval:1]]; [innerPool release]; } [outerPool release]; } -(void) forThreadTwo{ NSAutoreleasePool *outerPool = [[NSAutoreleasePool alloc] init]; while(1){ NSAutoreleasePool *innerPool = [[NSAutoreleasePool alloc] init]; NSLog(@"From two"); [NSThread sleepUntilDate:[[NSDate date] addTimeInterval:1]]; [innerPool release]; } [outerPool release]; }
@end ************************************************************************************
****************************************threadParent.h*****************************
#import <Foundation/Foundation.h>
@interface threadParent : NSObject
{ }
-init; -(void) forThreadOne; -(void) forThreadTwo; @end
************************************************************************************ |
[Prev in Thread] | Current Thread | [Next in Thread] |