3.2 Using Threads

Every process begins with a main thread (or primary thread) that is started when the process is created. This main thread or any subsequently created threads can use the CreateThread and CreateProcess functions to create additional threads or processes. Since the system can create and execute threads more quickly than processes, it is typically more efficient for an application to implement multitasking by distributing tasks among the threads of one process rather than by creating multiple processes. In some cases, however, it may be desirable to create separate processes. For example, you might want each thread of an application to have its own private address space to protect one thread from the activities of other threads. To do this, you would create multiple processes each with its own thread or threads.