c++ - Producer-consumer based multi-threading for image processing -
update: have provided reason of problem , solution in answer below. i want implement multi-threading based upon producer-consumer approach image processing task. case, producer thread should grabs images , put them container whereas consumer thread should extract images container thread. think should use queue implementation of container . i want use following code suggested in so answer . have become quite confused implementation of container , putting incoming image in producer thread. problem: image displayed first consumer thread not contain full data. and, second consumer thread never displays image. may be, there race situation or lock situation due second thread not able access data of queue @ all. have tried use mutex . #include <vector> #include <thread> #include <memory> #include <queue> #include <opencv2/highgui.hpp> #include <opencv2/core.hpp> #include <opencv2/imgproc.hpp> mutex mu; struct threadsafecontai...