java - producer consumer pattern finish signal -


i have application applies producer-consumer design pattern. written in java. in short, producers put items in blocking queue , consumers takes them there. consumers should run until signaled producer stop.

what neatest way deliver signal producers consumers? chief designer said wants keep producer , consumer separate dont see other other invoking method on consumer thread pool?

the chief programmer right. keeping them separate leads highly decoupled code excellent.

there several ways this. 1 of them called poison pill. here's how works - place known item on queue when consumer see item, kill or take action.

this can tricky if there multiple consumers (you mentioned threadpool) or bounded queues. please in java concurrency in practice joshua bloch. explained best.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -