Subj : SpiderMonkey threading issues To : netscape.public.mozilla.jseng From : Sean Proctor Date : Wed Mar 09 2005 04:05 pm Hello, After reading a lot of prior posts, it seems like what I am trying to do should work. So I think that I am missing something. I want to run a script from within one thread. In that script I am defining JS functions and passing them to a native (C) function. Those functions will be called under certain external conditions from another thread. The things I'm unsure of are: Do I need to use NSPR to create my threads? Right now I am using glib for that. Is there anything special I need to do with objects to use them in a different context from the one they were created in? Main thread: /* create context and associate global object */ cx = JS_NewContext (js_runtime, JS_CONTEXT_SIZE); JS_BeginRequest (cx); global = JS_NewObject(cx, &global_class, NULL, NULL); JS_InitStandardClasses(cx, global); Then I define my functions and execute the script. Nothing exciting there. Callback thread: /* create context */ cx = JS_NewContext (js_runtime, JS_CONTEXT_SIZE); JS_BeginRequest (cx); JS_SetGlobalObject (cx, global); /* C code to get the function and the parameters for it here */ /* call function */ JS_CallFunction (cx, global, function, 1, args, &rval); Thanks in advance, Sean .