• 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: Multithreading and memory management question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multithreading and memory management question


  • Subject: Re: Multithreading and memory management question
  • From: Ken Thomases <email@hidden>
  • Date: Thu, 21 Apr 2011 16:31:21 -0500

On Apr 21, 2011, at 4:18 PM, eveningnick eveningnick wrote:

> I have an application that has a shared object (which is a custom
> container for elements - arrays, and which is protected by critical
> sections in my code). I need to control it's lifetime - it should be
> alive until the last thread finishes working.

> Could you please suggest me how to achieve the removal of the object
> when i need it? In the most "pretty" way, if one exists.

How are you spawning your threads?  If you use Cocoa methods, then they automatically retain the object which is the target of the selector and the argument object for the life of the thread.  So, you may be getting this automatically without realizing it.  If not, then it should be easy to arrange.

If you're using some other technique to spawn your threads, you can just retain the object before spawning the thread and then have the thread work function or method release it before exiting.  The retain and the release don't have to occur on the same thread.

Regards,
Ken

_______________________________________________

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:
    • Re: Multithreading and memory management question
      • From: eveningnick eveningnick <email@hidden>
References: 
 >Multithreading and memory management question (From: eveningnick eveningnick <email@hidden>)

  • Prev by Date: Multithreading and memory management question
  • Next by Date: Re: Multithreading and memory management question
  • Previous by thread: Multithreading and memory management question
  • Next by thread: Re: Multithreading and memory management question
  • Index(es):
    • Date
    • Thread