Original Post
Hello,
I have a problem with the multithreading in c++, since I use it the first time. I have a std::queue, which will have added stuff at the front at random times by thread 1. Thread 2 then reads in the objects at the back of the queue and pops them out.
But since the queue is critical memory, the programm will spit out memoryerrors from time to time.
How can I make sure that the queue is not accessed by thread 2, when thread 1 needs to write. What I found on the www wasn't really helpful, so I hope you can help me out here!
Thanks a bunch.
I have a problem with the multithreading in c++, since I use it the first time. I have a std::queue, which will have added stuff at the front at random times by thread 1. Thread 2 then reads in the objects at the back of the queue and pops them out.
But since the queue is critical memory, the programm will spit out memoryerrors from time to time.
How can I make sure that the queue is not accessed by thread 2, when thread 1 needs to write. What I found on the www wasn't really helpful, so I hope you can help me out here!
Thanks a bunch.