Skip to content

Instantly share code, notes, and snippets.

@eleinadani
Last active February 5, 2019 16:14
Show Gist options
  • Save eleinadani/46330147704d75e38c9e879b6b818489 to your computer and use it in GitHub Desktop.
Save eleinadani/46330147704d75e38c9e879b6b818489 to your computer and use it in GitHub Desktop.
Context c1 = Context.create("js");
Context c2 = Context.create("js");
String jsCode = "(function(x,y) { return JSON.stringify({x:x,y:y}); })";
Value json1 = c1.eval("js", jsCode);
Value json2 = c2.eval("js", jsCode);
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
json1.execute(42,43).asString();
}
}
});
thread.start();
while (true) {
json2.execute(44,45).asString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment