In a custom queue, there's a push() and a pop() function. The pop() may be called any time on an Event.COMPLETE, so does this mean that code can be running in push() and pop() simultaneously? If so, is there a way to prevent the code from being run in both functions at the same time?
You need to google the concepts of an "atomic operation" in the context of "context switching", and also the idea of a mutex.
Basicly, a mutex is a boolean that gets set or cleared by your threads.
Each thread will:
function pop(){ Get_Mutex(); do_the_pop_operation(); Free_Mutex(); }
or
function push() { Get_Mutex(); do_the_push_operation(); Free_Mutex(); }
The Get_Mutex() function will sleep until it receives the mutex, thus only one operation can occur at a time.
No, Flash is exclusively single threaded so there's no way two operations can happen at the same time.
Basically you won't have to worry about other code having not finished executing when handling an event.
you should read the post by senocular on this one (see Events and Frame Execution specifically) Order of operations.
although flash might give the impression multithreading with some asynchronious operations, it is only a single threaded program so you never need to worry about locking. basically the event operation is run "between" frames, so the code running "on" the frame is completed before/after the events are run, so there is no worry of overlapping functions.