discuss-gnustep
[Top][All Lists]
Advanced

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

Thread exit


From: Wim Oudshoorn
Subject: Thread exit
Date: Tue, 01 Nov 2005 14:58:41 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/22.0.50 (darwin)

I just noticed in the documentation the following description:

  Note, unlike in Cocoa (and perhaps OpenStep), the thread will not
  exit when the method finishes execution. 

  You must call [Thread +exit] yourself (from the thread) to terminate
  it.

Is there a good reason for deviating from Cocoa?  
To me the Cocoa behaviour looks more natural.  The GNUstep
behaviour forces you to know if a method is started with 
[NSThread detachNewThread...].

So in a multi threaded program you should write a method 
as follows:

- doSomethingInteresting
{
        arp = [NSAutoreleasePool new];

        // Do interesting stuff

        DESTROY (arp)
        
        if we are stared from a different thread
           {
           [NSThread exit];
           }
}


The last part worries me, it seems you need to have knowledge
on how you are called.

I am probably missing something very obvious.


Wim Oudshoorn




reply via email to

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