Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AtomicInteger is implemented base on JNI?

Soneone told me that AtomicInteger is implemented using JNI, so it is much faster than synchonization. Is this true?

like image 280
user705414 Avatar asked Nov 17 '25 06:11

user705414


1 Answers

It is unlikely to be implemented based on JNI as this would imply significant overhead. Last time I looked the OpenJDK implementation is based on methods in sun.misc.Unsafe which are mostly implemented as JVM primitives (method calls that are implemented specially with native code in the JVM).

like image 66
Ramon Avatar answered Nov 19 '25 18:11

Ramon