FROM : James Bucanek
DATE : Sat Jun 17 22:11:30 2006
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
DATE : Sat Jun 17 22:11:30 2006
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
| Related mails | Author | Date |
|---|---|---|
| Marc Van Olmen | Jun 17, 20:26 | |
| James Bucanek | Jun 17, 22:11 | |
| Marc Van Olmen | Jun 17, 22:57 | |
| Marc Van Olmen | Jun 20, 03:02 | |
| John Stiles | Jun 20, 03:12 |






Cocoa mail archive

