• 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: Synchronized Editing Context for Locking/Unlocking
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Synchronized Editing Context for Locking/Unlocking


  • Subject: Re: Synchronized Editing Context for Locking/Unlocking
  • From: Ken Anderson <email@hidden>
  • Date: Fri, 3 Sep 2010 11:14:27 -0400

One other important point....

You should take great care to not end up with locks that cross each other.  I've run into huge problems when I try to synchronize sections of code that go in and out of EOF.  It's real easy to end up with:

thread 1:

synchronize (obj1)  - success
ec.lock()  -  waiting

thread 2:

ec.lock() - success
synchronize (obj1) - waiting

It's easy to avoid the obtuse cases of this, but when the code that locked the object makes a call to something else then a call to something else, it's very difficult to track down.

I ended up removing most synchronizes() from my apps and use implicit locking inside the EC to 'OK' access to other serializable things.

Ken

On Sep 3, 2010, at 7:59 AM, Farrukh Ijaz wrote:

> Hi,
>
> What is the difference between the two? I noticed both work almost the same way.
>
> Usage 1:
>
> try {
> 	editingContext().lock();
> 	// Do your stuff
> } finally {
> 	editingContext().unlock();
> }
>
> Usage 2:
>
> synchronized(editingContext()) {
> 	// Do your stuff
> }
>
> Thanks,
>
> Farrukh _______________________________________________
> 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

 _______________________________________________
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

References: 
 >Synchronized Editing Context for Locking/Unlocking (From: Farrukh Ijaz <email@hidden>)

  • Prev by Date: Re: Synchronized Editing Context for Locking/Unlocking
  • Next by Date: Re: WOO file
  • Previous by thread: Re: Synchronized Editing Context for Locking/Unlocking
  • Next by thread: EOEditingContext.isDisposed() ... ?
  • Index(es):
    • Date
    • Thread