I wonder, how is asynchronism implemented in AS3? Lets take the Timer
class. A timer runs asynchronously and dispatches some events. Seems like it creates a new thread for himself. And how are the functions, called when timer event occurs, being thread safe? How is thread safety implemented in AS3?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
AS3 now supports multi threading using "ActionScript Workers" in the latest build. You can see how it is used here in this preview...
http://www.bytearray.org/?p=4423
回答2:
AS3 [used to be] not multithreaded.
Prior to Flash Player 11.4, everything ran on the main (single) thread, which is why things like Timer
classes could be notoriously inaccurate if the CPU gets bogged down with some heavy processing.
As of Flash Player 11.4, Worker
objects were introduced, providing the ability to create multiple threads.