Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Cocoa/threading question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cocoa/threading question



I'm just starting to learn Cocoa and its implementation of threads, so this may seem like a stupid problem:

I have a program with two threads, the main one and the detached one. The detached one modifies and can delete several data structures, including a few linked lists. The main thread handles events and also drawing to the screen. Drawing to the screen involves traversing the linked lists and based on what they store, drawing different things. The problem is that when the detached thread decides to delete a list at the exact same time as when the main thread is trying to traverse that list, it crashes rather spectacularly.

How do I fix this, and prevent either thread from mucking with the data structures until the other is done? If possible, I'd like to do this entirely with Cocoa's threads -- no pthreads if possible.
_______________________________________________
studentdev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/studentdev
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.