There is a thread that keeps tracking new emails while a static variable tracking is true. It looks like this:
Thread thread = new Thread(new Runnable() {
    @Override
    public void run() {
        try  {
            tracking = true;
            while(tracking){
                //check emails
             }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
});
I implemented a function to stop tracking emails, that basically sets tracking to false.
Tracking is just a private static boolean which I use only inside the class that does these tasks.
Can this approach lead me to any problem?
 
     
     
     
    