'Python Queues and ThreadPoolExecutor

My question is around Queues and using ThreadPoolExecutor. If I understand the Python docs for Queues I can have code somewhat like this and not have to worry about needing another lock in Class B to control which thread is adding in items in to the queue? Since the Queue implments multiproducer, multiconsumer

class A:
    def __init__(max_worker = 1):
        pool = ThreadPoolExecutor(max_worker)
        buffer = {}
        _lock = threading.RLock()
        
    def add_record_id(id, item):
        with self._lock:
            buffer[id].add(item, pool)

class B:
    def __init__():
        q = queue.Queue()

    def add(item, pool):
     if id >= 0:
        q.put(item)
        pool.submit(background_remover)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source