← 返回 meta 的题目列表Thread-Safe Deque Implementation with Multi-thread Synchronization
类型:online_judge
meta
Design a system to safely operate a deque in a multi-threading environment.
Define the data structure for a deque.
Describe in detail how to safely operate the deque in a multi-threading environment without causing race conditions.
Assume two threads call the same operation simultaneously and design a solution to handle it.
Requirements: Provide a complete code implementation and add test cases to verify thread safety.
Example
Input
append_left 10
append_right 20
pop_right
pop_left