I'm new to Java, so pls excuse if answer to below simple case is obvious.
class A{
public void foo(Customer cust){
cust.setName(cust.getFirstName() + " " + cust.getLastName());
cust.setAddress(new Address("Rome"));
}
}
I've a Singleton object (objectA
) created for class A
.
Given I don't have any class variable, is it thread safe if I call
objectA.foo(new Customer())
from different threads?What if I change foo to static and call
A.foo(new Customer())
from different threads? is it still thread safe?