Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: crashing problem due to buckyball timer exception inNSAppleScript class



On Dec 29, 2004, at 2:21 PM, email@hidden wrote:
| This applies to every piece of functionality that isn't thread-safe
| unless explicitly documented otherwise.

"Not thread-safe" means only that the thread-unsafe item (variable, function, whatever) can't be safely used in more than one thread at the same time. However, it *can* be used from more than one thread as long as the uses *do not overlap*, as long as one thread is completely done with the item before another thread starts using it.

Sorry but this is incorrect, at least for Cocoa and Carbon. Unless a facility is documented as being usable from a non-main thread, it is not necessarily safe to use it from a non-main thread.


It's true that NSAppleScript must be assumed non-thread-safe (since it's not stated to be thread-safe), but that's not why it must be used only from the event-dispatch thread. *That* restriction stems from the fact that AppleScripts use events to send commands and data back and forth; the AppleScript must be run on the main event loop or the events it depends on won't get sent to it.

That may be *why* NSAppleScript can only be used from the main thread. But you can't apply this reasoning to determine whether any arbitrary piece of functionality is safe to call on a non-main thread.


All you have to go on is the documentation. The documentation does not say NSAppleScript is thread-safe. Therefore you cannot assume you can safely use NSAppleScript from multiple threads at once. The documentation does not say NSAppleScript can be used from a non-main thread. Therefore you cannot assume you can safely use NSAppleScript from a non-main thread.

  -- Chris

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >crashing problem due to buckyball timer exception in NSAppleScript class (From: IMD <email@hidden>)
 >Re: crashing problem due to buckyball timer exception in NSAppleScript class (From: Chris Hanson <email@hidden>)
 >Re: crashing problem due to buckyball timer exception inNSAppleScript class (From: email@hidden)



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.