Background:
In my application written in C++, I have created 3 threads:
Edit: Ok, since you are using busy spin to block on the queue, this is most likely the cause for high CPU usage. The OS is under the impression that your threads are doing useful work when they are actually not, so they get full CPU time. There was interesting discussion here: Which one is better for performance to check another threads boolean in java
I advise you to either switch to events or other blocking mechanisms or use some synchronized queue instead and see how it goes.
Also, that reasoning about the queue being thread-safe "because only two threads are using it" is very dangerous.
Assuming the queue is implemented as a linked list, imagine what can happen if it has only one or two elements remaining. Since you have no way of controlling the relative speeds of the producer and the consumer, this may well be the case and so you're in big trouble.