Explain Threads for Executing Concurrent Application Code
The thread has been introduced in many operating systems as an efficient mechanism for executing concurrent application code. The thread is best defined as light-weight process. While a thread owns a minimal amount of data, its main job is to execute application code efficiently. Therefore, starting and ending threads uses much less overhead than processes and minimizes the use of system resources. Threads allow more concurrency to occur with lesser overhead. With a thread-based system, it might be possible to assign one thread per remote client. This model is known as the Worker Model and will maximize all clients' use of the server processor. Threads are important because they can increase the ability to handle requests generated from client machines.
Applications architected for thread use can see very significant performance gains as well. The reason is simple; an operating system is much more efficient in creating, executing, and switching threads within a system than it is with process. The developer is uniformly presented with a simple API to create and manipulate thread execution. The thread API allows the developer to specify an arbitrary function at which the new thread is to be started. Priorities, inheritance, and privileges may either be passed or implied, depending on the platform. Optionally, the developer is allowed to create and manage a thread's stack or have the system do it. The specific API is not as important as the functionality provided.