← 返回 linkedin 的题目列表Thread-Safe MultiPut Blocking Queue Implementation and Tests
类型:online_judge
linkedin
Implement a class named MultiPutBlockingQueue which functions as a multiple producer-consumer blocking queue. This queue supports simultaneous operations by multiple producers and consumers. Implement the method multiPut(List<T> items) which adds all elements of a list into the queue, ensuring that no mixing occurs with items from other calls. Note: multiPut must be thread-safe. Consider implementation strategies like using the synchronized keyword. Please provide a complete implementation with at least five test cases.
Example
Input
[1, 2, 3, 4, 5]