Suggest data-structure for this use case : <p>Language: Java</p>

<p>I have a fixed pool of threads running, all of who have to ask a question and take user input in the form of (Yes/No) at some point, which would basically decide its further execution. Since I don't want to intermingle the output questions from multiple threads, there will be another task/thread running (single) at fixed rate (Further referred as main thread), which can be used to get the questions and display it to the user. The number of questions asked by the thread may vary and once the question gets a response, it is no longer needed again.</p>

<p>At this point my current implementation uses <code>LinkedTransferQueue</code>, which basically allows me to share data between main thread and question thread without having to wait for polling.</p>

<p>I have created a synchronized <code>ArrayList</code> of a <code>Task</code> class, each of which contains a <code>LinkedTransferQueue&lt;String&gt;</code>. The thread creates a new <code>Task</code> and adds its question into its queue with <code>transfer()</code> method. The main thread picks them up and gets response from user, which is put back to the same queue. The advantage here is that <code>LinkedTransferQueue</code> offers a <code>take()</code> method that allows me to wait without polling.</p>

<p>Other approaches include using a <code>volatile shared</code> variable, whose value is updated by main thread and is constantly being polled by the other thread. </p>

<p>Please suggest if any other data structure is available for such a use case. This is not exactly a producer-consumer problem from what I can understand. Post questions if you have any other concerns.</p>

<p>Thanks!!</p>
