Java provides atomic package that support lock-free thread-safe programming on single variables. This is especially useful when you want to use some primitive as global variable but also care about thread-safety.
Now, this classes from this package will help you but it doesn't provide a direct AtomicDouble
class, but it tells you how to achieve that, see below note from the documentation:
Atomic classes are not general purpose replacements for
java.lang.Integer and related classes. They do not define methods such
as equals, hashCode and compareTo. (Because atomic variables are
expected to be mutated, they are poor choices for hash table keys.)
Additionally, classes are provided only for those types that are
commonly useful in intended applications. For example, there is no
atomic class for representing byte. In those infrequent cases where
you would like to do so, you can use an AtomicInteger to hold byte
values, and cast appropriately. You can also hold floats using
Float.floatToRawIntBits(float) and Float.intBitsToFloat(int)
conversions, and doubles using Double.doubleToRawLongBits(double) and
Double.longBitsToDouble(long) conversions.
Do read
this answer as well.