I am working with synchronization for the first time. I wrote some code that I have to implement in my current work. I wanted to know if I am doing it right or am I making a mistake. Whenever a new list of data is downloaded, NewDataArrived() is called. This method then calls the ListData() that returns the list of previously saved data. There is another class running in parallel that uses the ListData(). What I want to do is whenever the List is being updated, the Thread class should just wait until the list is updated.public class ListData() {/****/public List < name_holder > getList() {    synchronized(LOCK_LIST) {        if (newDataArrived)            LOCK_LIST.notifyAll();        return full_list;    }}void NewDataArrived() {    newDataArrived = true;    parallelDownload p = new parallelDownload();    p.start();    getList().addAll(my_list);    newDataArrived = false;}class parallelDownload extends Thread {    private Object o = new Object();    @Override    public void run() {        synchronized(o) {            for (name_holder n: getList()) {                while (newDataArrived) {                    try {                        o.wait();                    } catch (InterruptedException e) {                        e.printStackTrace();                    }                }            }        }    }}}
Synchronization of new data with previous data
java;android;synchronization