Monday, March 13, 2006

Multithreaded Job Queue - The Code Project - Threads, Processes & IPC

Multithreaded Job Queue - The Code Project - Threads, Processes & IPC: "In many of our applications we just want to get some thing done asynchronously. This is where some times we prefer to use job queue. Where we can just assign or add a job to the job queue and then it is the job queue's responsibilities to complete the job. This gives the flexibility to the main thread to concentrate on some thing else where the jobs can be processed at the background. If the job queue can be multithreaded and can process multiple jobs at the same time, it is better.

This article describes such an implementation of job queue. This implementation has the following features :

* The job queue is multi threaded, so many jobs can be processed simultaneously. The job queue uses a pool of threads to execute the jobs.
* The job queue supports priorities. The jobs with high priority will be added before the jobs with lower priority, in the queue. So they will be processed before other lower priority jobs.
* The job queue can be paused, so that no new job can be processed from the time of pause. But the user still can add jobs to the queue. The jobs will be processed once the user choose to resume the job queue.
* The number of threads that will be used by the job queue to process the jobs can be increased or decreased at run time.

Background"

No comments: