A context is bound to a thread, and is its self stateless. You simply need
one context per thread. But your scope is the container under which your
scripts run. You can execute the same scope under different contexts, thus
accomplishing your goal. Think of the context as a per-thread stateless
engine, and the scope as the container for all of your javascript objects.
Technically you could even run two scripts under the same context (the same
set of javascript objects) from two different contexts/threads (however I
doubt many people do this as you would need to handle the concurrency issues
yourself).

Hope that sheds some light.
Dave


-----Original Message-----
From:
dev-tech-js-engine-rhino-bounces+davidparks21=yahoo....@lists.mozilla.org
[mailto:dev-tech-js-engine-rhino-bounces+davidparks21=yahoo....@lists.mozill
a.org] On Behalf Of Jyrki Saarinen
Sent: Friday, August 07, 2009 3:16 PM
To: [email protected]
Subject: Context and threads

Hi all,

I need to execute JS in different threads, but in the same Context. From 
what I understand
about the Rhino source, one Context is associated with one thread?

Is it possible somehow to share the Context between two (or more) 
threads? Why is
Context bound into a thread?

Jyrki

_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino


_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to