FROM : Shawn Erickson
DATE : Wed Apr 04 19:42:01 2007
On Apr 4, 2007, at 10:28 AM, Ruotger Skupin wrote:
> Hi,
>
> a short CoreData question. according to the manual:
>
> Managed objects themselves are not thread safe. In order to work
> with a managed object across different threads, you should lock its
> context (see NSLocking).
>
> Does that mean I can do a
>
> @synchronized(myManagedObjectContext)
> {
> // .. do stuff
> }
>
> or do I have to do a:
>
> [myManagedObjectContext lock];
> {
> // .. do stuff
> }
> [myManagedObjectContext unlock];
The later otherwise you are likely not using the same locking construct.
In general I believe the recommend practice is to not attempt to
modify a given managed object instance across threads but instead use
a managed object context per thread and only modify the objects you
get from the context on that given thread.
-Shawn
DATE : Wed Apr 04 19:42:01 2007
On Apr 4, 2007, at 10:28 AM, Ruotger Skupin wrote:
> Hi,
>
> a short CoreData question. according to the manual:
>
> Managed objects themselves are not thread safe. In order to work
> with a managed object across different threads, you should lock its
> context (see NSLocking).
>
> Does that mean I can do a
>
> @synchronized(myManagedObjectContext)
> {
> // .. do stuff
> }
>
> or do I have to do a:
>
> [myManagedObjectContext lock];
> {
> // .. do stuff
> }
> [myManagedObjectContext unlock];
The later otherwise you are likely not using the same locking construct.
In general I believe the recommend practice is to not attempt to
modify a given managed object instance across threads but instead use
a managed object context per thread and only modify the objects you
get from the context on that given thread.
-Shawn
| Related mails | Author | Date |
|---|---|---|
| Ruotger Skupin | Apr 4, 19:28 | |
| Shawn Erickson | Apr 4, 19:42 | |
| Jim Correia | Apr 4, 19:45 |






Cocoa mail archive

