What is a thread? What are the advantages we derived by programming with thread? Threads allow programs to execute simultaneously. A thread is an independent path of execution in a program. These threads can be executed synchronously or asynchronously. All threads have a priority attached. Thread with a higher priority is executed first.
Advantages: - Allows multiple programs to be executed concurrently - Cost of thread is low compared to processes in terms of space and communication. - Threads are lightweight. What is a thread? What are the advantages we derived by programming with thread? A thread is a fork of a program into two or more concurrently running tasks.
Since a thread runs independent of the other tasks in a computer, an entire program wouldn’t be held up due to one CPU intensive task or due to an infinite loop. So the other tasks that don't get stuck in the loop can continue processing without waiting for the stuck task to finish.
|