Threading and concurrency

Jurassic is not thread-safe. However, it also does not use any thread-local or global state. Therefore, as long as you ensure that no Jurassic object is called from multiple threads at once, it will work. The easiest way to ensure this is to use multiple script engines (one per thread is ideal). Since non-primitive objects are tied to a single script engine, each script engine is fully isolated from one another. This does make sharing data between script engines hard. One way to share data is to serialize it into a string and then pass it between threads (the JSON object is available to serialize JavaScript objects).

Last edited Aug 5, 2010 at 10:59 AM by paulbartrum, version 2

Comments

No comments yet.