• 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: How do I guarantee that an object is dealloced on the main thread?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I guarantee that an object is dealloced on the main thread?


  • Subject: Re: How do I guarantee that an object is dealloced on the main thread?
  • From: Jim Correia <email@hidden>
  • Date: Sun, 5 Oct 2008 16:52:51 -0400

On Oct 5, 2008, at 4:43 PM, Brian Stern wrote:

This is the question I really wanted to ask:

I have an object X that is alloc/inited on the main thread. This object creates some NSThreads with detachNewThreadSelector:toTarget:withObject, which have object X as their target. At a later point I want to release object X and have it be dealloced on the main thread.

How do I guarantee that object X is dealloced on the main thread?

The problem is this: the NSThread objects retain object X. I have a stop method in object X that sets a 'cancelled' global that the thread objects inspect and they then exit when it turns true. So I send stop and then release on the main thread. The thread objects exit and eventually release object X but the last release, which causes the dealloc, can be on any thread.

The real question is, why do you care what thread the -dealloc method runs on?


What non-memory management side effects does your -dealloc method have which much be run on the main thread?

Jim
_______________________________________________

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: How do I guarantee that an object is dealloced on the main thread?
      • From: Brian Stern <email@hidden>
References: 
 >How do I guarantee that an object is dealloced on the main thread? (From: Brian Stern <email@hidden>)

  • Prev by Date: How do I guarantee that an object is dealloced on the main thread?
  • Next by Date: Binding NSTableView Double Click argument and target to file's owner
  • Previous by thread: How do I guarantee that an object is dealloced on the main thread?
  • Next by thread: Re: How do I guarantee that an object is dealloced on the main thread?
  • Index(es):
    • Date
    • Thread