Пример #1
0
void producer_put(int id, BlockingQueue & queue) {
    for (int i = 0; i < 75; ++i) {
        int data = i;
        queue.put(data);
        cout << "Producer " << id << " put " << data << endl;
        this_thread::sleep_for(chrono::milliseconds(100));
    }
}
Пример #2
0
int main(int argc, char *argv[])
{
    BlockingQueue<std::string> queue;

    queue.put("Hello");
    queue.put("World");

    std::cout << queue.take() << std::endl;
    std::cout << queue.take() << std::endl;

    return 0;
}