• 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: NSTask is "Thread Unsafe". What does that mean?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask is "Thread Unsafe". What does that mean?


  • Subject: Re: NSTask is "Thread Unsafe". What does that mean?
  • From: "Adam R. Maxwell" <email@hidden>
  • Date: Mon, 14 Sep 2009 07:41:51 -0700


On Sep 14, 2009, at 7:07 AM, Jerry Krinock wrote:

According to the Threading Programming Guide [1], NSTask is listed under "Thread Unsafe Classes", which is explained as:

"The following classes and functions are generally not thread-safe. In most cases, you can use these classes from any thread as long as you use them from only one thread at a time. Check the class documentation for additional details."

[...]

What does NSTask being "Thread Unsafe" mean to you?

Ordinarily, I'd guess that it's supposed to mean that you can't share instances between threads. However, guesswork when dealing with the threading docs drives me crazy.


For NSTask in particular, I recommend that you interpret that more conservatively, since (at least prior to 10.5) there's a subtle race condition in the implementation that causes some really nasty problems when you try to spawn tasks from multiple threads simultaneously. Things may or may not be fixed in 10.5 and 10.6, and whether you run into it also depends on your hardware and the number of tasks you use. Over several years, we had multiple reports of the problem, but only one user was able to reproduce it consistently. I wrote an implementation of NSTask from scratch to work around the problem.


Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Need -[NSTask waitUntilExitOrTimeout:] (was NSTask "Thread Unsafe"...)
      • From: Jerry Krinock <email@hidden>
References: 
 >NSTask is "Thread Unsafe". What does that mean? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: NSTask is "Thread Unsafe". What does that mean?
  • Next by Date: Re: NSTextView resizeability and scrolling
  • Previous by thread: NSTask is "Thread Unsafe". What does that mean?
  • Next by thread: Need -[NSTask waitUntilExitOrTimeout:] (was NSTask "Thread Unsafe"...)
  • Index(es):
    • Date
    • Thread