I am filling a table on tabhost after login. I have set up a thread to fill in the table. Meanwhile I click on the tab where I have set up another thread to read the data from the same table and fill the adapter for the list view.
My problem is that the thread which fills the table on tabhost takes some time and meanwhile if I click on the tab to show the data from table it shows no data found because of the adapter being empty.
How to solve this? Is it something like producer/consumer which can be solved using wait() and notify()?
Easiest (aka hackiest) way I can imagine?
Create a static boolean set to false in your main activity. Have the background thread set it to true once it has updated the data. The other activity can check if the boolean is false and send you back to main or put up a toast stating the data is still loading.
Or just if no data is found, simply put up a toast that you are loading. You can have a timer running to refresh the page until data is found.