• 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: is NSNotificationCenter thread safe?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: is NSNotificationCenter thread safe?


  • Subject: Re: is NSNotificationCenter thread safe?
  • From: Chuck Hill <email@hidden>
  • Date: Wed, 4 Jun 2008 13:42:04 -0700


On Jun 4, 2008, at 1:30 PM, Florijan Stamenkovic wrote:


On Jun 04, 2008, at 13:32, Chuck Hill wrote:


On Jun 4, 2008, at 1:56 AM, Freddie Tilley wrote:

Is the java version of NSNotificationCenter thread safe?

What do you mean? What are you doing, and what do you expect the results to be?


Yes, it is used by WebObjects internally to broadcast EOF and other changes across threads.



And does it support posting from on thread to another similiar the Object-C version of NSDistributedNotificationCenter


Notifications are broadcast in the same thread context that they are sent in. It is up to the threads getting the notification to handle the appropriately for whatever work they are engaged in. I am not sure if that answers your question or not.

Chuck, could you clarify? I'm not sure I read you right. It is my assumption that the notification center does not do any thread handling whatsoever. Basically that the callback method is called on the same thread that posted the notification, without even considering any other threads involved. Is that what you're saying?

Yes. Along with the fact that the receiving object needs to be aware that some other thread will call that method while it is executing and handle it appropriately. In the case of an EC, if it is locked, it queues the notifications until it is unlocked. Simple synchronization would suffice in other cases. But you need to be aware of concurrency when receiving notifications. That should be obvious, but I have managed to overlook some of the implications from time to time.



I've always thought NSNotification center is a rather simple, straight-forward player.

It is, but a threaded, concurrent environment can hold many interesting surprises ("oh right, this page is not in an R-R loop when that notification arrives"). :-)


Chuck

--

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects






_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: is NSNotificationCenter thread safe?
      • From: Florijan Stamenkovic <email@hidden>
References: 
 >is NSNotificationCenter thread safe? (From: Freddie Tilley <email@hidden>)
 >Re: is NSNotificationCenter thread safe? (From: Chuck Hill <email@hidden>)
 >Re: is NSNotificationCenter thread safe? (From: Florijan Stamenkovic <email@hidden>)

  • Prev by Date: Re: is NSNotificationCenter thread safe?
  • Next by Date: Re: is NSNotificationCenter thread safe?
  • Previous by thread: Re: is NSNotificationCenter thread safe?
  • Next by thread: Re: is NSNotificationCenter thread safe?
  • Index(es):
    • Date
    • Thread