I want to implement a multithreaded queue as in this example
But my problem is to understand the complete model.
In order to let every single thread push/pop into the same queue, i have to make the SafeQueue a Singleton. Is this correct?
And than i need some thread-safe singleton initialisation?
It should look like this:
____________
| |
| Thread 1 | ---------
|__________| |
|
____________ ----------> ____________
| | | |
| Thread 2 | ------------------> | Queue |
|__________| |__________|
--------->
____________ |
| | |
| Thread 3 |-----------
|__________|
Or should i initiate the queue before creating the threads and pass the Queue-Object into every single Thread?