use automic boolean for flush synchronization