Environment: Spring Container
Say i have the service layer configured as Singleton
and that there are no instance variables (state variables) in the service class.
@Singleton
class MyService{
public List<String> getNames(){
List<String> list = entityManager.createQuery("");
list.add("uknown");
return list;
}
}
If there are multiple requests (multiple threads) trying to access simultaneously the method getNames()
, is it possible to have any synchronization problems?
For example, is it possible for a request to return the "uknown" name twice?