synchronized (this) {
System.setProperty("org.jruby.embed.localcontext.scope", "singlethread");
System.setProperty("org.jruby.embed.localvariable.behavior", "global");
ScriptEngineManager manager = new ScriptEngineManager();
List<ScriptEngineFactory> factories = manager.getEngineFactories();
ScriptEngineFactory factory = null;
while (factories.iterator().hasNext()) {
factory = factories.iterator().next();
if ("ruby".equals(factory.getLanguageName())) {
break;
}
}
engine1 = factory.getScriptEngine();
engine2 = factory.getScriptEngine();
}
engine1.put("Value", "value of the first engine");
engine2.put("Value", new Double(-0.0149));
Object obj1 = engine1.eval("$Value + 2010.to_s");
Object obj2 = engine2.eval("$Value + 2010");