Fw: Code excerpt, running in OpenStep and failing in GNUstep!

"ramana rao" <[email protected]>
Newsgroups gmane.comp.lib.gnustep.applications
Organization Orillion
Message-ID <008401c162e6$92fb08d0$7501a8c0@nalluri>
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

************************************************************************************
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.