Header Ads

Header ADS

practical 1:write a program to work with a single thread

 #write a program to work with a single thread

import threading


class MyThread(threading.Thread):

    def __init__(self, thread_name, thread_id):

        threading.Thread.__init__(self)

        self.thread_name = thread_name

        self.thread_id = thread_id


    def run(self):

        print(str(self.thread_name) + " " + str(self.thread_id))


thread1 = MyThread("gfg",  1000)

thread2 = MyThread(" geeksforGeeks", 2000)


thread1.start()

thread2.start()


thread1.join()  # Wait for thread1 to finish

thread2.join()  # Wait for thread2 to finish


print("exit")


No comments

Powered by Blogger.