import threading
import time

event=threading.Event()

def light():
    count=0
    while True:
        if count<=5:
            event.set()
            print('\033[42;1m--green light on---\033[0m')

        elif 5<count<=10:
            event.clear()
            print('\033[43;1m--yellow light on---\033[0m')
        else:
            event.clear()
            print('\033[41;1m--red light on---\033[0m')
            if count>=15:
                count=0
        time.sleep(1)
        count+=1

def car(name):
    while True:
        if event.is_set():
            print("%s running..." % name)
            time.sleep(1)
        else:
            print("car is waiting...")
            event.wait()
            
Light=threading.Thread(target=light,)
Light.start()
Car=threading.Thread(target=car,args=("Benz",))
Car.start()