Added volatile keyword to loop boolean.