I have two thread and a ArrayList in my program. I want to access list from my threads.
public void run() {
...
arraylist.add(myObj);
...
}
public void run() {
...
arraylist.remove(myObj);
...
}
I tried Synchronization each of thread.
synchronized (arraylist)
{
//add or remove
}
but it said "Synchronization of non-final field".