| 63 | from threading import Lock |
| 64 | |
| 65 | class MyQueue: |
| 66 | def __init__(self): |
| 67 | self.items = deque() |
| 68 | self.lock = Lock() |
| 69 | |
| 70 | |
| 71 | print("Example 3") |
| 72 | def put(self, item): |
| 73 | with self.lock: |
| 74 | self.items.append(item) |
| 75 | |
| 76 | |
| 77 | print("Example 4") |
| 78 | def get(self): |
| 79 | with self.lock: |
| 80 | return self.items.popleft() |
| 81 | |
| 82 | |
| 83 | print("Example 5") |