Threadsafe FIFO Queue/Buffer
问题 I need to implement a sort of task buffer. Basic requirements are: Process tasks in a single background thread Receive tasks from multiple threads Process ALL received tasks i.e. make sure buffer is drained of buffered tasks after a stop signal is received Order of tasks received per thread must be maintained I was thinking of implementing it using a Queue like below. Would appreciate feedback on the implementation. Are there any other brighter ideas to implement such a thing? public class