Adding java wait when file is locked