aruna sydu wrote:Hi All,
One of my friends came up with the below question.
I have a method in which I am operating on a ArrayList like adding elements removing etc etc.
Now when n * Threads access the method will there be any issue with the ArrayList data. Should the ArrayList be Synchronized ?
It was also mentioned that ArrayList was declared and initialized in the same local method. !
Any insights will be appreciated.
Thanks !
No matter how many threads are running concurrently , each thread will have its own copy of local variable. now since you mentioned that ArrayList is declared and initialized in the same method ,hence it becomes local variable. so each thread will have its own copy of arraylist. so there will not be any conflicts.