Open GoogleCodeExporter opened 9 years ago
In fact, V8 doesn't support multithread at all, please ensure you lock the
engine before execute script. Jav8 may provide engine level lock later, but
JSR223 seems doesn't have any interface about it :(
Original comment by flier...@gmail.com
on 23 Dec 2013 at 11:26
Had the same problem... Putting scriptEngine.eval(...) inside a synchronized
block solved the issue.
Original comment by konrad.p...@actiworks.de
on 8 Jan 2014 at 11:16
synchronizing the eval block doesn't "solve" the issue. The benefit of a
multithreading environment for a scripting engine is to be able to execute
multiple evaluations concurrently. By the way, JSR-223 is very clear about it:
"
Multithreaded Engine
Multi-threaded Evaluation - The implementation of the API and the
engine itself are capable of supporting concurrent evaluations by
multiple threads on a single engine instance. However the exact
behavior of such concurrent execution is ultimately determined by the
script or scripts themselves. An engine which supports concurrent
execution is "multi-threaded" in the same sense that the Java language
is "multi-threaded": Evaluation by concurrent threads is allowed and
produces side effects that can be seen by other threads. The threads
may interact or not interact, utilize synchronization or not utilize
synchronization, in scripting language dependent ways.
"
http://download.oracle.com/otn-pub/jcp/java_scripting-1.0-fr-oth-JSpec/java_scri
pting-1_0-fr-spec.pdf, page 163
Current implementation is not compliant with spec. I am not criticising, jav8
is a great initiative, but this issue is a real blocker for real application
cases.
Original comment by bhlangon...@gmail.com
on 8 Mar 2014 at 7:18
Another correction: V8 does support a multithreading environment by using
Isolates and Lockers. A thread-isolated engine would suffice for making jav8
ScriptEngine implementation thread safe and thus supporting a multi-threaded
environment.
Original comment by bhlangon...@gmail.com
on 8 Mar 2014 at 8:27
Agree, jav8 hard to meet requirements of "Multithreaded Engine", but we could
catch up thread-isolated base on V8 isolated mechanism.
Original comment by flier...@gmail.com
on 10 Mar 2014 at 9:16
Yes, it is definitely a fix and comply with specs if done that way. I am
looking forward to it.
Original comment by bhlangon...@gmail.com
on 10 Mar 2014 at 11:54
Original issue reported on code.google.com by
marcov...@gmail.com
on 13 Apr 2013 at 7:27Attachments: