• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Killing a stuck NSThread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Killing a stuck NSThread
      • From: Ivan Kourtev <email@hidden>
References: 
 >Killing a stuck NSThread (From: Dustin Wenz <email@hidden>)

  • Prev by Date: Re: Flipping over coordinate conversion
  • Next by Date: Re: Killing a stuck NSThread
  • Previous by thread: Killing a stuck NSThread
  • Next by thread: Re: Killing a stuck NSThread
  • Index(es):
    • Date
    • Thread