workqueue queue queue( threads [threadid create new threads for thread_name in thread_listthread sample_thread(threadidthread_nameworkqueuethread start(threads append(threadthreadid + fill the queue queuelock acquire(for items in name_listworkqueue put(itemsqueuelock release(wait for the queue to empty while not workqueue empty()pass notify threads it' time to exit thread_exit_flag wait for all threads to complete for in threadst join(print ("exit main thread"outputinitializing thread- initializing thread- initializing thread- thread- processing athread- processing thread- processing thread- processing thread- processing exiting thread- exiting thread- exiting thread- exit main thread