#48 | Python Tutorials in Tamil | Creating and Starting Thread in Python Using Threading Package

Опубликовано: 13 Декабрь 2018
на канале: SANTRA TECHSPOT
9,448
163

#48 | Python Tutorials in Tamil | Creating and Staring Thread in Python Using Threading Package

Running several threads is similar to running several different programs concurrently, but with the following benefits −

Multiple threads within a process share the same data space with the main thread and can therefore share information or communicate with each other more easily than if they were separate processes.

Threads are sometimes called light-weight processes and they do not require much memory overhead; they are cheaper than processes.

A thread has a beginning, an execution sequence, and a conclusion. It has an instruction pointer that keeps track of where within its context is it currently running.

It can be pre-empted (interrupted).

It can temporarily be put on hold (also known as sleeping) while other threads are running - this is called yielding.

There are two different kind of threads −

kernel thread
user thread
Kernel Threads are a part of the operating system, while the User-space threads are not implemented in the kernel.

There are two modules which support the usage of threads in Python3 −

_thread
threading
The thread module has been "deprecated" for quite a long time. Users are encouraged to use the threading module instead. Hence, in Python 3, the module "thread" is not available anymore. However, it has been renamed to "_thread" for backwards compatibilities in Python3.

Starting a New Thread
To spawn another thread, you need to call the following method available in the thread module −

_thread.start_new_thread ( function, args[, kwargs] )
This method call enables a fast and efficient way to create new threads in both Linux and Windows.

The method call returns immediately and the child thread starts and calls function with the passed list of args. When the function returns, the thread terminates.

Here, args is a tuple of arguments; use an empty tuple to call function without passing any arguments. kwargs is an optional dictionary of keyword arguments.
c tutorial link -    • C Programming Tutorials in Tamil | Pa...  

oops link -    • Learn Object Oriented Programming in ...  

html5 link -    • 1# Introduction to HTML5 programming ...  

css3 link -    • PART-1 INTRODUCTION TO  CSS3 AND ITS ...  

javascript link -    • PART-1 INTRODUCTION TO  CSS3 AND ITS ...  

python link    • #1 - Python Tutorial in Tamil | Intro...  

c tricks -    • ADD TWO NUMBERS WITHOUT USING ARITHME...  

c interview questions -    • Find The Output Of the Program in Tamil  

sample program -    • HOW TO WRITE C PROGRAM FOR BASIC ADDI...  

c++ program -    • PART-01 INTRODUCTION TO C++ PROGRAMMI...  

vb6 tutorial -    • Visual Basic 6 Tutorial in Tamil  

__
like our face book page..
  / santratechspot  
--------------------------------------------------------------------------------
send request our channel official facebookprofile...
  / santra.techspot.5  
---------------------------------------------------------------------------------

#santratechspot #python #tutorial