• 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: Thread safety, some basic questions about accessing mutable objects across threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thread safety, some basic questions about accessing mutable objects across threads


  • Subject: Re: Thread safety, some basic questions about accessing mutable objects across threads
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 06 Aug 2013 11:12:06 -0700

On Aug 6, 2013, at 8:39 AM, Nick Rogers <email@hidden> wrote:

> 1. Created a mutable array in main thread, can I read its values in a secondary thread safely, while no other thread is modifying this mutable array?

Yes. Most non-thread-safe objects don’t care what threads you call them on, so long as they’re only called on one thread at a time. So you can use locks or @synchronized blocks to coordinate access.

(The exceptions are higher-level things that use runloops or dispatch queues, such as NSURLConnection, NSStream, etc. Those usually need to be called only from the same thread/queue they’re scheduled on, because they’re also getting callbacks on that same thread/queue.)

—Jens
_______________________________________________

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


References: 
 >Thread safety, some basic questions about accessing mutable objects across threads (From: Nick Rogers <email@hidden>)

  • Prev by Date: Re: Any way to delay drawing after scrolling?
  • Next by Date: Reloading table view header or footer
  • Previous by thread: Re: Thread safety, some basic questions about accessing mutable objects across threads
  • Next by thread: Re: Thread safety, some basic questions about accessing mutable objects across threads
  • Index(es):
    • Date
    • Thread