Subj : Executing 2 scripts in parallel using the same global object To : netscape.public.mozilla.jseng From : "Harizakis Costas" Date : Wed Jun 04 2003 07:57 pm I was wondering how can I execute 2 scripts in paraller (using 2 threads), using the save global object. Given the following: - Create a native thread - Initialize the runtime and associate it with a context. - Associate the context with a global object (initializing the common js classes) - Declare some functions (as properties of the global object). Suppose that a new native thread is created, and wishes to execute one of the globally -previously- declared functions; Which are the necessary steps in order to do it safely using the thread-safe build of the js-engine? The JS_[Get|Set|Clear]ContextThread() functions as also the JS_[Begin|End]Request() do not clarify under which circumstances it is safe to execute 2 scripts concurrently or if deadlocks may arise. Will the creation of a 2nd context for the 2nd thread allow me to reference objects created on the 1st context? Does this imply that the JS_[Begin|End]Request() calls may be omitted? Example: - The 1st thread is executing a script. - While in a native function a new thread is created (or an existing one gets signalled) - The new thread executes a pre-compiled script (same context). - Both threads continue executing. - The 1st thread completes and returns control to the user. - User continue executing C code. - The 2nd thread completes sometime later - any results are stored in the js context. Is the above example realizable? If yes which thread related JS_xxx() functions should be called and when? Thanks in advance, Costas .