×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

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!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.