@Slf4j
@Service
public class SendServiceImpl implements SendService {
private final MessageService messageService;
private Message message;
public SendServiceImpl (MessageService messageService) {
this.messageService = messageService;
}
@Transactional
@Override
public void send(String messageGuid) {
message = messageService.getOne(messageGuid);
//...
}
Is this class thread safe? what problems can there be if I run in 5 threads like this:
taskExecutor.execute(() -> sendService .send(someGuid);//5 different guids
in practice, I studied the logs file and saw that with the same entity work different threads. Do I understand correctly that in this case, threads can change the value of entity message
if I declared message like class field?
Can anyone explain this in detail?