Pregunta de entrevista de ByteDance

They asked me to explain the difference between optimistic locking and pessimistic locking, and when each approach should be used in real applications.