I have this below code.
private static volatile Properties props = null;
private static volatile StanfordCoreNLP pipeline = null;
/**
*
* @return
*/
static {
if (props == null) {
props = new Properties();
props.setProperty("annotators", "tokenize, ssplit, parse, sentiment");
}
if (pipeline == null) {
pipeline = new StanfordCoreNLP(props);
}
}
I want to have a single instance of variable props
and pipeline
across my entire application which is multithreaded.
Is my code right or I am missing something?
Thanks.