Hi,
It might be a noob question, but still... would like know.
"When do one decide that that he needs a thread".
One usually describes producer-consumer example in multi threading. But
producer-consumer can still happen in single thread like:
// pseudo-code
main()
{
int info[10];
producer(); //fills info
consumer(); //empties info
}
or
main()
{
producer();
}
producer()
{
int info[10];
// do some processing to fill info-array
consumer(info);
}
But in what scenario one decides that we need producer() and consumer()
to run in separate threads. We all know that consumer() anyhow has to
wait for info to be filled in producer(), whether it is single-threaded
or multi-threaded.
Thanks.
Knowledge Seeker