27 lines
790 B
Python
27 lines
790 B
Python
import time
|
|
import threading
|
|
|
|
def countdown_timer(countdown_time, timer_id):
|
|
while countdown_time > 0:
|
|
mins, secs = divmod(countdown_time, 60)
|
|
time_format = '{:02d}:{:02d}'.format(mins, secs)
|
|
print(f"Timer {timer_id}: {time_format}", end='\r') # Print the time remaining
|
|
time.sleep(1) # Wait for 1 second
|
|
countdown_time -= 1
|
|
print(f"Timer {timer_id}: Cek status mesin")
|
|
|
|
# Create multiple countdown timers
|
|
timer1 = threading.Thread(target=countdown_timer, args=(10, 1))
|
|
timer2 = threading.Thread(target=countdown_timer, args=(15, 2))
|
|
timer3 = threading.Thread(target=countdown_timer, args=(20, 3))
|
|
|
|
# Start the timers
|
|
timer1.start()
|
|
timer2.start()
|
|
timer3.start()
|
|
|
|
# Wait for all timers to complete
|
|
timer1.join()
|
|
timer2.join()
|
|
timer3.join()
|