Multithreading replaces event loop programming by dividing the tasks into discrete and logical units. Threads also helps in avoiding polling. Polling is usually implemented by a loop that is used to check some condition repeatedly. Once the condition is true, appropriate action is taken, this results in wastage of CPU time. Suppose that the producer has to wait until the consumer is finished before it generates more data. In a polling system, the consumer would waste many CPU cycles while it waits for the producer to produce. Once the producer has finished, it would start polling, wasting more CPU cycles waiting for the consumer to finish, and so on.