alloc init thread safe?
alloc init thread safe?
- Subject: alloc init thread safe?
- From: email@hidden
- Date: Wed, 7 Mar 2007 23:25:10 -0700
I have one object of Class1. This object has a method
- (id) C2_alloc_init {
return [[Class2 alloc] init];
}
This method can be called from multiple threads simultaneously.
Sometimes this would return null, and it appears from the trace
messages that this occurs when it is being called from two threads at
about the same time. Both classes are subclasses of NSObject.
The problem seems to be solved by putting a lock around the alloc
init calls, doing an unlock before returning the value.
So did I miss some documentation that says alloc init are not thread
safe? Or at least alloc?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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