using lock to sync threads using the settings file