Can AtomicInteger replace synchronized?

后端 未结 5 1007
不思量自难忘°
不思量自难忘° 2020-12-31 02:21

The javadoc for the java.util.concurrent.atomic package says the following:

A small toolkit of classes that support lock-free thread-safe programm

5条回答
  •  感动是毒
    2020-12-31 02:37

    Yes, they're functionally equivalent.

    If you're in an ultra-high contention environment, you may see performance differences, but that's highly unlikely.

提交回复
热议问题