• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: DO vs NSLock with threads and AppKit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Should I use _NSObsoleteMenuItemProtocol in validateMenuItem()?
  • Next by Date: menu enabling/disabling in Java
  • Previous by thread: Re: DO vs NSLock with threads and AppKit
  • Next by thread: Interthread comms for progress bars
  • Index(es):
    • Date
    • Thread