A
A
antonwx2020-08-07 22:23:35
Java
antonwx, 2020-08-07 22:23:35

Is it enough to set the volatile property to a variable in order to work with it from several threads without any problems?

Actually the question is this: I have a variable, a string with data, with which one thread constantly works, but in read-only mode, and another thread periodically writes data to this variable. Will it be enough to add a volatile property to the variable so that no problems arise?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-08-07
@antonwx

In the described scenario it is enough.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question