sscasc@tumkur what are threadsthreads (sometimes called lightweight processesare similar to processes except that they all execute within the same processthus all share the same context they can be thought of as "mini-processesrunning in parallel within main process or "main thread thread has beginningan execution sequenceand conclusion it has an instruction pointer that keeps track of where within its context it is currently running it can be pre-empted (interruptedand temporarily put on hold (also known as sleepingwhile other threads are running--this is called yielding multiple threads within 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 generally executed in concurrent fashionand it is this parallelism and data sharing that enable the coordination of multiple tasks naturallythreads are scheduled in such way that they run for little bitthen yield to other threads throughout the execution of the entire processeach thread performs its ownseparate tasksand communicates the results with other threads as necessary if two or more threads access the same piece of datainconsistent results may arise because of the ordering of data access this is commonly known as race condition the thread libraries come with synchronization functions which allow the thread manager to control execution and access some threads may not be given equal and fair execution time this is because some functions block until they have completed multithreadingis the ability of cpu to manage the use of operating system by executing multiple threads concurrently the main idea of multithreading is to achieve parallelism by dividing process into multiple threads states of thread to understand the functionality of threads in depthwe need to learn about the lifecycle of the threads or the different thread states typicallya thread can exist in five distinct states the different states are shown belownew thread new thread begins its life cycle in the new state butat this stageit has not yet started and it has not been allocated any resources we can say that it is just an instance of an object runnable as the newly born thread is startedthe thread becomes runnable waiting to run in this stateit has all the resources but still task scheduler have not scheduled it to run sp_python programming