1. A non-transitory machine readable medium storing a program that when executed by at least one processing unit processes packets, the program comprising sets of instructions for: generating and installing flows in a cache, wherein each flow is generated using at least one rule, from a flow table, which specifies performing a set of actions on incoming packets; validating one or more of the flows that are installed in the cache by determining whether a set of actions in each flow matches a corresponding rule in the flow table, wherein each flow is assigned to a separate execution thread to be validated; and removing or modifying each flow that has a different set of actions than a corresponding rule in the flow table in order to improve a performance of packet processing, wherein said generating and installing flows are executed in a first set of execution threads and said validating, removing, and modifying are executed in a second, different set of execution threads.