Hey Vardhan, I had referred this blog and it helped me a lot, thank you soo much.
My interview went pretty fine. I was asked 6 questions and answered all except there was this one question "can you make array volatile in java" and i froze coz i didn't know the answer. But I did the research and found it out.
Yes you can make an array volatile in java but only reference pointing to an array will be visible to all threads, not the whole array.
suppose you have a reference variable called primes as shown below:
protected volatile int[] primes = new int[10];
then if you assign a new array to primes variable, change will be visible to all threads, but changes to individual indices will not be covered under volatile guarantee i.e.
primes = new int[20];
will follow the "happens-before" rule and cause memory barrier refresh, but following code will not do so
primes[0] = 10;
primes[1] = 20;
primes[2] = 30;
primes[3] = 40;
Probably you should add this in your blog so it might be helpful for the others.