0 votes
in JAVA by
Can we make array volatile in Java?

1 Answer

0 votes
by

This is one of the tricky Java multi-threading questions you will see in senior Java developer Interview. Yes, you can make an array volatile in Java but only the reference which is pointing to an array, not the whole array. What I mean, if one thread changes the reference variable to points to another array, that will provide a volatile guarantee, but if multiple threads are changing individual array elements they won't be having happens before guarantee provided by the volatile modifier.

Related questions

0 votes
asked Feb 9, 2021 in JAVA by SakshiSharma
0 votes
asked May 2, 2021 in JAVA by sharadyadav1986
...