c# - do we need to lock this queue? -
If there is only one thread to add to the queue and there is only one thread to get from the queue, then lock it The queue for those access works is not necessary, I think
will usually be in a loop retrieved. If he misses an item, then it will be found in the next attempt only Anxiety is receiving partial data. If this value is type queue and value is larger than a basic memory unit, then it can be. But if this is a reference type, then it should be fine.
Am I right?
Assume that you are talking about qi & lt; T & gt;
.
Unless the thread is writing and the thread that is reading is the same thread, then no lock is necessary. If they are different threads then yes, actually a lock is necessary. The documentation clearly states that if lockers are required for readers and writers on different threads
Comments
Post a Comment