What is the difference between optimistic and pessimistic locking?

Technical