-
Notifications
You must be signed in to change notification settings - Fork 124
Threading and concurrency
paulbartrum edited this page Dec 14, 2015
·
1 revision
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).