What is Concurrency and its types

When two or more people try to update same type of data then Concurrency helps how to handle this situation there are two types of concurrency

Pessimistic:-When one user try to change the data with pessimistic concurrency a lock is placed on the data so that another user cannot change that one after one another can change.

Optimistic:-In this if two user works on the same data and one change that data first then second user cannot change

that same data becasue the which he have using is allready changed so he cannot do the change becasue change apply to another data that is changed by first user.