Let us first start by understanding what exactly a thread is in computer programs. Thread is widely viewed as a short form of thread of execution. Threads basically split a computer program into two or more tasks to make the running of a program easier. Processes and threads can be different in the way they are structured from one operating system to another. However these threads may share resources making multitasking easy in modern day computers. Thread consumes very little resources and are referred to as light weight.
You can also take threads as lanes on a highway. Let each lane have a certain set of code that runs. As a user, imagine yourself on the interaction lane. If you perhaps try running a HTTP GET, it might be very slow. How about if the command was ran on its own thread? It is quicker. This means that the resources are distributed and shared for each function making the program run faster and more efficiently without unnecessarily exhausting resources in the computer.
Threads and processes in a computer have one ultimate goal. The threads are aimed at getting the computer do lots of things at a time. To make that possible, a computer has a processor that helps in switching tasks smoothly during operation. It is important to note each computer program might have several processes when running. The process also has an address and flow of control as well. The process generally assists you to know what each thread is involved in. even when you are running multiple programs on one computer, each program runs on several threads. When you too many programs on your computer, it sometimes may become slow since there is a high rate of shared resources.
Multitasking operating systems like windows or Linux when running a large computer may give the CPU time to turn each computer on. Some computers have several CPUs, so that each CPU can be assigned a specific task. This is quite easy for simple applications. Large applications like word processors may actually look like multiple programs that have lots of communication and switching between them. One large problem is however the fact that the CPUs might take time to switch the threads and processes amongst them.
Modern CPUs therefore have memory management units that will ensure that there are no overriding processes and threads. Moving from one process to another means that the memory management unit moves process and restores process information too. This is exactly the same reason why you might require computers with larger CPU capabilities to ensure that even huge programs run smoothly.
The advantage of having threads in place of process is that computers have an easy time switching threads as compared to processes. This is due to the fact that there is no need for switch of the address spaces. Additionally, the threads share common address spaces and thus can communicate easily with each other.