There's more...

All the operations between the producer class and the consumer class can easily be resumed with the following schema:

Thread synchronization with the queue module
  • The Producer thread acquires the lock and then inserts data in the QUEUE data structure.
  • The Consumer threads get the integers from the QUEUE. These threads acquire the lock before removing data from the QUEUE.

If the QUEUE is empty, then the consumer threads get in a waiting state.

With this recipe, the chapter dedicated to thread-based parallelism comes to an end.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.147.190