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
Post a Comment