Hi,
The following class is not thread-safe (as proven in http://stackoverflow.com/questions/2410499/proving-the-following-code-not-thread-safe )
Is there a framework out there that can help with either compile time / run time analysis and tell us that the following is not thread safe?
For compile time, ideally in Eclipse the wiggly underline comes up and tells us that the class is not thread safe?
For run time, will any the static code analysis catch the class as non-thread-safe?
public class LazyInitRace {
private ExpensiveObject instance = null;
public ExpensiveObject getInstance() {
if (instance == null)
instance = new ExpensiveObject();
return instance;
}
}