I correctly say that synchronized use is always pessimistic and the use of CAS ( AtomicInteger and other classes) is always optimistic
Yes you are right.
Traditional locking mechanisms, for example. using a synchronized keyword in java is called a pessimistic method of blocking or multithreading.
An optimistic approach is similar to the old adage: “It’s easier to get forgiveness than permission,” where “easier” here means “more effective”. CAS is an example of an optimistic method. StampedLock also supports optimistic locking.
source share