ADVERTISEMENT
ADVERTISEMENT

Python program to illustrate naming of threads

Here, we are going to learn about the naming of threads with example.
Submitted by Shivang Yadav, on February 19, 2021

Threads are small units that can be processed by OS, and are sub parts of a process.

Python uses the threading library to support multithreading and some more functions. The method allows the user to give names to their threads which can be accessed later on using, 

Python program to illustrate naming of threads

import threading

def ProcessOne():
    while(True):
        print(threading.current_thread().getName(),"is Running")

def ProcessTwo():
    while(True):
        print(threading.current_thread().getName(),"is Running")


T1=threading.Thread(target=ProcessOne,name="Swift")
T2=threading.Thread(target=ProcessTwo,name='Alto')

T1.start()
T2.start()

Output:

Swift is Running
Alto is Running 
...
...

Python Threading Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.