Re: Killing a stuck NSThread
Re: Killing a stuck NSThread
- Subject: Re: Killing a stuck NSThread
- From: Axel Andersson <email@hidden>
- Date: Wed, 26 Apr 2006 22:02:02 +0200
On Apr 26, 2006, at 20:56, Dustin Wenz wrote:
I have an application that spawns an NSThread to perform a blocking
network operation. Sometimes the operation takes too long to
execute and needs to be cancelled or killed by the main thread.
Cancelling a thread is generally very hard to get right, and not
something commonly recommended. Consider communicating that the other
thread should exit via some status variable instead. As you're
working with blocking sockets, look into the mechanisms for testing
socket read/writes with a timeout, so that you can break out of the
network operation every once in a while and check your status
variable. Alternatively, use that timeout itself to determine when
the operation has taken too long.
http://developer.apple.com/documentation/Cocoa/Conceptual/
Multithreading/index.html
http://developer.apple.com/documentation/Darwin/Reference/ManPages/
man2/select.2.html
-- Axel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden