Multithreading in the AS3

Source: Internet
Author: User

Starting with fp11.4 support for worker technology, the threading concept in AS3, in fp11.5, FLASCC began supporting pthread families to create threads.

In general, there are two ways to create threads in AS3:

1. Use the worker family interface directly in AS3 to create and use threads.

2. Use FLASCC technology to create and use a thread in C using the Pthread family interface. Adobe's official documentation clearly states that threads created with Pthread are ultimately implemented using workers in AS3.

  

I. Creation and acquisition of worker objects

1. Access to workers created using the worker family interface

There are three ways, as follows:

1.1 Direct Access when creating a worker

var worker:worker = WorkerDomain.current.createWorker (swfbytes);

1.2 Use worker.current to get the thread where the current code is located.

1.3 Use WorkerDomain.current.listWorkers () to get the current list of all the workers.

2. Access to workers created using the Pthread family interface

Because the threads created with Pthread_create actually eventually generate a worker to run, there is also a fetch for the worker object. However, this can only be achieved by using the 1.2 and 1.3 methods, and there is no way to directly use 1.1 to put the thread creator to get the currently created worker. For this reason, it may cause inconvenience to the user.

Ii. communication between the worker

Iii. on the relationship between Pthread and worker

1. Thread proc function and worker loading (constructor, added to stage event) sequence relationship.

2, if a thread proc is a dead loop function, then the worker itself can handle its own events, such as enter frame.

3, about the performance of the pthread and the common worker, memory use test comparison.

Multithreading in the AS3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.