Skip to content

Instantly share code, notes, and snippets.

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