Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best threading queue example / best practice [closed]

I have data that needs to be executed on a certain background thread. I have code coming from all other threads that need to call into this. does anyone have a good tutorial or best practice on having a queue for synchronization to support this threading requirement

like image 351
leora Avatar asked Dec 06 '08 13:12

leora


2 Answers

Check out Threading in C#, by Joseph Albahari, very complete reference about multithreading. In particular, he covers producer/consumer queues.

like image 102
Mauricio Scheffer Avatar answered Sep 21 '22 07:09

Mauricio Scheffer


You could either:

  • implement a producer/consumer model (which use not thread-safe generic queue)
  • or use in your background thread a synchronized queue, which does comment on the process of Enumerating through a collection.
like image 36
VonC Avatar answered Sep 21 '22 07:09

VonC