One of my java static method is accessed by multiple threads . Do I need to synchronize the method explicitly by synchronized keyword?.
Sometime back I read in a book which states that
static method is implicitly thread safe as the method is not object specific
.
Well known example is , Singleton implementation. In which getInstance() is static and do we need to mark this as synchronized as well?
public synchronized static Logger getInstance() {
if( instance == null ){
instance = new Logger();
}
return instance;
}
Thanks