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 protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/kenlists%40anderhome.com
>
> This email sent to [email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]