Threading Question
-
Is there any way, when implementing a lock, that an incoming thread can force its own priority over the ones currently queued? i.e. i've got 10 threads waiting to add items to a stack, and a thread that copies, empties and leaves the lock to process the copied items. I don't want to wait N milliseconds for the items to be added to the stack as the processing thread is a priority, so i want the processing thread to jump to the front of the lock queue. Is this possible? And how could i do it? Cheers guys Tristan Rhodes
-
Is there any way, when implementing a lock, that an incoming thread can force its own priority over the ones currently queued? i.e. i've got 10 threads waiting to add items to a stack, and a thread that copies, empties and leaves the lock to process the copied items. I don't want to wait N milliseconds for the items to be added to the stack as the processing thread is a priority, so i want the processing thread to jump to the front of the lock queue. Is this possible? And how could i do it? Cheers guys Tristan Rhodes
Interesting quesiton. I don't believe setting the thread priority has anything to do with the acceesing the lock, I thought it was a FIFO construct. Never really thought about type of situation though.
only two letters away from being an asset
-
Is there any way, when implementing a lock, that an incoming thread can force its own priority over the ones currently queued? i.e. i've got 10 threads waiting to add items to a stack, and a thread that copies, empties and leaves the lock to process the copied items. I don't want to wait N milliseconds for the items to be added to the stack as the processing thread is a priority, so i want the processing thread to jump to the front of the lock queue. Is this possible? And how could i do it? Cheers guys Tristan Rhodes
I did something similar when I implemented my SmartThreadPool. Check my article: http://www.codeproject.com/cs/threads/smartthreadpool.asp[^]. I implemented a special queue that items are queued FIFO, but waiters queue LIFO. You can change the code to get what you want. Ami