I am doing a project on a print spooler. I am using multithreading to support multiple clients.
The problem is that I need another thread on the server side to take care of the printing by extracting jobs from a priority queue. If the queue is empty the thread must be idle and when a job comes it must service it.
How do i go about this? Where do i start the print thread? And from where do i let the thread know that a job has entered into a previously empty thread?

Use a LinkedBlockingQueue for the server - you'll find examples on the web.

Use a LinkedBlockingQueue for the server - you'll find examples on the web.

I am using a priority blocking queue. Is that alright? I need to use a priority queue!

Yes, absolutely. LinkedBlockingQueue is FIFO, I missed the bit where you said "priority", sorry.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.