Skip to main content

Program to creating a thread to print the even numbers from 10 to 20 by using Thread Class

· One min read
Kaustubh Kulkarni

Que > Program to creating a thread to print the even numbers from 10 to 20 by using Thread Class

file.py
from _thread import *
import threading as thread
def even(name,timer):
for i in range(10,20):
if i%2==0:
print(name+" : "+str(i))
try:
thread.start_new_thread( even, ("Thread", 2, ) )
except Exception as e:
print ("Error: ",e)
Output
Thread : 10
Thread : 12
Thread : 14
Thread : 16
Thread : 18