Skip to main content
added 209 characters in body
Source Link
Martin Maat
  • 18.7k
  • 3
  • 33
  • 59

I do not fully understand what your application does but your concerns and approaches seem off.

  • Do not mess with thread priorities, these will give you nothing.
  • If you do not want reads and writes to get in each others way, just lock on the queue object.
  • a read thread looking in a queue to find nothing is there (yet) is not a bad thing. Trying to control the order in which different threads run is pointless and defeats the purpose of threads.
  • do not do work within the lock, only lock while using the shared resource, that is write to the queue or read from the queue.
  • Put the read thread to sleep for a while before looking for new items again.

I do not fully understand what your application does but your concerns and approaches seem off.

  • Do not mess with thread priorities, these will give you nothing.
  • If you do not want reads and writes to get in each others way, just lock on the queue object.
  • a read thread looking in a queue to find nothing is there (yet) is not a bad thing. Trying to control the order in which different threads run is pointless and defeats the purpose of threads.

I do not fully understand what your application does but your concerns and approaches seem off.

  • Do not mess with thread priorities, these will give you nothing.
  • If you do not want reads and writes to get in each others way, just lock on the queue object.
  • a read thread looking in a queue to find nothing is there (yet) is not a bad thing. Trying to control the order in which different threads run is pointless and defeats the purpose of threads.
  • do not do work within the lock, only lock while using the shared resource, that is write to the queue or read from the queue.
  • Put the read thread to sleep for a while before looking for new items again.
Source Link
Martin Maat
  • 18.7k
  • 3
  • 33
  • 59

I do not fully understand what your application does but your concerns and approaches seem off.

  • Do not mess with thread priorities, these will give you nothing.
  • If you do not want reads and writes to get in each others way, just lock on the queue object.
  • a read thread looking in a queue to find nothing is there (yet) is not a bad thing. Trying to control the order in which different threads run is pointless and defeats the purpose of threads.