Stumbled upon following code in an existing codebase I am looking at. there are other similar calls which "set" values to "myService' etc. Confirming that following piece isn't threadsafe given myService is not "local" and two threads entering createUser at the same time and calling "myService.newUser" at the same time will corrupt the subsequent persona.firstName and persona.lastName etc. Is this understanding correct?
object WFService {
lazy private val myService = engine.getMyService
def createUser(persona: Persona): String = {
val user = myService.newUser(persona.id.toString)
persona.firstName.map(n => user.setFirstName(n))
persona.lastName.map(n => user.setLastName(n))