What is "Atomic integer" in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is "Atomic integer" in java?

private static final AtomicInteger i = new AtomicInteger(1);

20th Jun 2018, 10:49 AM
Star Lord
Star Lord - avatar
1 Answer
+ 1
It allows you to use Atomic operations. If you have multi threading application than simple increment like i++ may end with wrong result. That's why it's better to use atomic operations.
20th Jun 2018, 11:29 AM
Lstiti