I have a
with pointers inside in a C++
application. I know there are two threads
to access it.
will add pointers from the back and Thread2
will process and remove pointers from the front.
will wait until
reach certain of amount, saying 10 items, and then start to process it. It will only loop and process 10 items at a time. In the meantime, Thread1
may still keep adding new items into the deque.
I think it will be fine without synchronize
are accessing different part of the
. It is
. So there is no case that the existing memory of the
will be reallocated.
Am I right? if not, why (I want to know what I am missing)?
I know it will not hurt to ALWAYS synchronize it. But it may hurt the performance or not necessary. I just want it run faster and correctly if possible.