added the try-finally statement and the volatile option to the instance variables