Actors in Swift prevent data races by ensuring that only one task can access their internal data at a time. When multiple tasks want to change or read data, they send messages to the actor. The actor processes these messages one after another, never at the same time. This serialization means the data stays consistent and safe. In the example, the actor Counter has a value variable and an increment method. Even if many tasks call increment simultaneously, the actor handles each call in order, updating the value safely. This prevents the common problem of data races where two tasks might try to change the same data at once and cause errors. Reading the value after increments is also safe because the actor ensures all writes finish first. Using actors is a simple way to keep data safe in concurrent Swift programs.