Re: DO Connections
Re: DO Connections
- Subject: Re: DO Connections
- From: Buzz Andersen <email@hidden>
- Date: Wed, 30 Oct 2002 10:13:24 -0700
>
If the separate class running my second NSThread is locked into a
>
continuous while loop, how can the main thread inform the secondary
>
thread that the socket is supposed to close? Is there a way to share a
>
memory address for a BOOL and safely have both threads access it?
I do a similar thing in a program of mine, but I simply have a BOOL
instance variable called isRunning in my "server" class and an accessor
that the client can use to set the value. The while loop simply checks
this value every time it runs, and exits if it sees that it has been
set to "NO" by the client thread.
In order to give the client direct access to my server class (so that
it can change the isRunning variable), I simply have a method called
"setServer:" that the server uses to give the client a reference to
itself. The client simply caches this reference and sets isRunning to
"NO" when it wants the thread to exit.
I think this arrangement is OK-- it seems to work great so far, and I
*did* pattern it after an example in the Anguish/Buck/Yacktman Cocoa
book :-).
--
Buzz Andersen
email: email@hidden
web:
http://www.scifihifi.com
_______________________________________________
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.