How can you avoid race conditions in a map reduce script with multiple threads in which an action is carried out only once for each vendor, and then a checkbox is checked off preventing it from happening again? Perhaps an additional checkbox that only allows the function to be executed when it's unchecked and prevents other threads from executing the function until the said second checkbox is unchecked?