Hello,

I am trying to embed JavaScript into my Java application, and got a
bit confused with the contexts.

JavaDoc for Context.enter() says this:

"Instead of using enter(), exit() pair consider using
call(ContextAction) which guarantees proper association of Context
instances with the current thread and is faster."

And the doc for call(ContextAction) says this:

"If no Context is associated with the thread, then
ContextFactory.getGlobal().makeContext() will be called to construct
new Context instance. The instance will be temporary associated with
the thread during call to ContextAction.run(Context)."

What confuses me is the word "temporary". Does that mean that it is
not guaranteed that an already existing context (previously allocated
for the current thread) will be re-used? What is the proper way to
avoid allocation of more than one context per thread?

Also, when do I need to call Context.exit()? Is it reasonable to do a
Context.enter() once at the start of the thread that will execute
JavaScript and never exit it?

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

Reply via email to