Here you can find the source of getScriptEngine()
private static ScriptEngine getScriptEngine()
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; public class Main { private static HashMap<Long, ScriptEngine> context = new HashMap<Long, ScriptEngine>(); private static ScriptEngine getScriptEngine() { long id = Thread.currentThread().getId(); ScriptEngine engine = context.get(id); if (engine == null) { ScriptEngineManager engineManager = new ScriptEngineManager(); engine = engineManager.getEngineByName("nashorn"); context.put(id, engine);/*from www. jav a 2s.co m*/ } return engine; } }