created and implemented SaveThread class for saving in a background thread.