Switching from polling to event based system
<p>Basically what i am trying to achieve is to check whether the data has been changed or not since the last time i checked.</p>

<p>What i am doing here is i initiate a separate thread that continuously runs in a loop and checks the stop variable at the end of the loop. The stop variable is a global variable so i can easily give it a 0 value to terminate the polling loop from the main thread.</p>

<p>In the loop i have a set of variables that hold the value of data that i retrieved in the previous iteration and a set of variables that are used to store the recently retrieved data. All i do is compare the variable with the new data with the ones that are holding the previous data. After this i update the set of variables that are holding the previous data to the most recent data.</p>

<p>I wanted to ask if there is a more efficient way of doing this? maybe something that would not require polling?</p>