Dear all

Could you tell me what is it-atomic type in Java? I explored internet and book Java in 21 days,but nothing about it. The question was about difference between object reference and atomic type. I found that object reference is an address that indicates where an object's variable and methods are stored.

Thank you

There is no atomic "type" in Java.

All of the classes in the java.util.concurrent.atomic package have the "Atomic" prefix in their names.

All of those classes "...provide atomic access to arrays of values and provide volatile access semantics for array elements, which is not possible with the volatile modifier itself." (Java in a Nutshell 5th Edition, pg. 855)

volatile Roughly speaking, a volatile field is like a synchronized method: safe for concurrent use by two or more threads. More accurately, volatile says that the value of a field must always be read from and flushed to main memory, and that it may not be cached by a thread (in a register or CPU cache).

I hope that answers your question. :)

Comments
I just learned something new. Good job

An atomic type in the context referred to most likely should be read as a primitive type.

That's int, long, double, float, byte, and char.
They don't refer to Object references, like everything else.

And technically primitives are stored in a different memory space from object instances (but not the references you deal with to those instances).
But they can be stored in different memory spaces depending on where and how they're created, where object instances are always created in the same space.

This article has been dead for over six months. Start a new discussion instead.