Re: DO vs NSLock with threads and AppKit
Re: DO vs NSLock with threads and AppKit
- Subject: Re: DO vs NSLock with threads and AppKit
- From: Andreas Wolf <email@hidden>
- Date: Mon, 23 Jul 2001 09:40:56 -0700
I understand that the AppKit is not thread safe. I am a little confused,
however, about when you can use an NSLock to make it thread safe versus
when
you must use DO.
For instance, if I am simply sending a setStringValue to an NSTextField,
should I use DO, or will an NSLock be good enough?
Are there cases when an NSLock would not work as opposed to DO?
You have to access the NSTextField from the main thread or memory will
leak and worse things will happen.
If the String you want to display is modified in a different thread you
have to NSLock it.
For me it worked best with C-Strings, i.e. I share C-Strings among
multiple Threads and everytime
I access them I NSLock them.
IMHO, for the task you mentioned (string in NSTextField) DO would be too
much work
(for both, you and the CPU :)
-Andreas