я начал разбираться с потоками в питоне и не могу понять почему в этом случае поток с бесконечным циклом завершает свою работу
import threading
from time import sleep
mutex = threading.Lock()
not_empty = threading.Condition(mutex)
def worker():
    print("Thread start")
    
    while True:
        print('111 ', end='')
            
        with not_empty:         # here
            not_empty.wait()    # here
        
        print('222')
        sleep(0.5)
threading.Thread(target=worker).start()
print('All work completed')
Thread start
111 All work completed
А в этом случае продолжает работать бесконечно (закомментировал две строки отмеченных комментарием #here):
import threading
from time import sleep
mutex = threading.Lock()
not_empty = threading.Condition(mutex)
def worker():
    print("Thread start")
    
    while True:
        print('111 ', end='')
            
        #with not_empty:         # here
        #    not_empty.wait()    # here
        
        print('222')
        sleep(0.5)
threading.Thread(target=worker).start()
print('All work completed')
Thread start
111 222
All work completed
111 222
111 222
111 222
111 222
111 222
111 222
111 222
111 222
111 222
111 222
111 222
...