Re: NSThread in Debug mode loading code issue
Re: NSThread in Debug mode loading code issue
- Subject: Re: NSThread in Debug mode loading code issue
- From: James Bucanek <email@hidden>
- Date: Sat, 17 Jun 2006 13:11:30 -0700
Marc Van Olmen wrote on Saturday, June 17, 2006:
>hi,
>
>I create a thread that is doing the following:
>
> anObject = [[MyBitmap alloc] initWithContents:aPath];
>
>When I create 2 of those threads right after each other. There is an
>issue that in one of the threads the variable
>anObject == NULL.
>I noticed that in the other thread it is like busy loading the code
>for MyBitmap ( it is busy loading also some CoreGraphics code.
>
>So my guess is that the ZeroLink has issues when it is loading a
>class and not 2 threads can do this at the same time?
I doubt this has anything to do with ZeroLink, other than the timing of ZeroLink is probably exposing a race condition in your code. Or, said another way, ZeroLink slightly purturbs the timing of your application and you see the bug.
If I had to take a wild guess (and without any other details), I'd say that anObject is probably a global or an instance variable of an object and you've started two threads using the same object. These two threads are, therefore, sharing the same variable and one is clearing the value while the second thread is trying to use it. This is pretty common multi-thread bug.
James
--
James Bucanek
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden