On Apr 7, 2:42 pm, Norris Boyd <[EMAIL PROTECTED]> wrote:
> On Apr 7, 12:08 pm, [EMAIL PROTECTED] wrote:
>
>
>
> > Hi Guys,
>
> > I know every time calling Context.enter(), we must call Context.exit()
> > after interpreting script.
> > But I still have questions about that.
>
> > 1. If I uses one dedicated thread to interpret script(this thread is
> > reused), must I every time call
> > Context.enter() before interpreting script and Context.exit()  after
> > interpreting script?
>
> > Can I just call one time Context.enter() when start this thread, then
> > this thread interprets many script. At last can I let this thread die
> > by itself at last without calling Context.exit()
>
> > 2. What does Context really do and what Rhino store in Context? Does
> > it hold any resource, we have to call Context.exit() explicitly to
> > release them.
>
> > Thanks.
>
> > nbruce
>
> Rhino stores information about the configuration and runtime state of
> the JavaScript execution in a Context object.
>
> The first Context.enter() on a given thread creates a Context and a
> ThreadLocal, and references the Context from the ThreadLocal.
> Subsequent calls to Context.enter() on that thread return the
> associated Context. So if you let a thread die without calling
> Context.exit() on it, the ThreadLocal will be collected along with the
> associated Context. However, it isn't recommended to do this as
> ContextFactory allows clients to register listeners that are invoked
> with the Context is released; these listeners won't be called if you
> don't call Context.exit(). The Rhino debugger registers a listener for
> that event but doesn't perform any processing, so you could likely get
> away with it now but could cause problems with other services or in
> future versions of Rhino.
>
> --Norris

Thanks Norris. It's great help for me.
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to