Tobias, We'll look into removing the doPrivileged on first entry (security is checked elsewhere), but we need to do a security assessment before proceeding.
That said, I would recommend as a best practice to use a per-thread JavaScript loop instead, to avoid such issues. I generally use a java.util.concurrent.LinkedBlockingQueue to "feed" the loop from other threads. Cheers, -- Jim On 2013-07-17, at 12:37 PM, Tobias Schlottke <[email protected]> wrote: > Hi there, > > I've built a small case where I evaluate a compiled script equipped with a > custom bindings. > The script is equipped with some variables and and compiled like this: > > engine.put("shopId", "test"); > runner = (Bindings) > engine.compile(ad.getCondition_script().getCode()).eval(); > > afterwards, I execute the "run" method on the object returned by eval() like > this: > > return (MyCustomObject) engine.invokeMethod(runner, "run", attr); > > the run method does local compilations but does not change anything so > basically the runner is immutable. > I access it from various threads. > > When profiling the code I see a lot of time spent in > java.security.AccessController.doPrivileged() which is invoked in > setNashornGlobal() if the globals changed. > I'm a bit unsure what changed globals really mean because in my case nothing > (either context nor bindings) changed and I wonder if it is necessary. > > Best, > > Tobias
