As per javadoc, RythmEngine class is not thread safe I.e. each time I have to build a new class which looks like an overhead. What is the best way to use rythm engine in multi threaded envioronment.
Below sample code is for illustration.
import java.io.File;
import java.util.Map;
import org.rythmengine.RythmEngine;
public class RythmEngineUtil {
static RythmEngine engine;
static {
Map<String, Object> conf;// = configure the object
engine = new RythmEngine(conf);
}
public static String render(File file, Map<String,Object> param){
return engine.render(file, param);
}
}
If you construct and init the engine when you app bootstrap, then that instance should be safely used in a multi-threaded environment