Every process has at least one thread, known as the main thread. However, threads can spawn other threads of execution. All threads within a process share the same data segment (constants, static variables and global variables) and the same virtual address space. However each has its own independent stack. All active threads in a process get an equal share of CPU time, thus they operate concurrently. If the system has multiple cores, separate threads can also operate simultaneously.
In multi-tasking environments, concurrent threads are vital. For instance, rather than the main thread performing tasks it can initialise its environment and then enter an "idle mode", a tight loop that simply monitors a message queue and dispatches those messages accordingly. If a message indicates that a lengthy task must be performed, the main thread would be unable to monitor the message queue for the duration of that task and the application becomes unresponsive to user-input while that task is going on. But if the task is delegated to a "worker thread", the main thread can continue to accept user-input. Meanwhile the worker thread can complete its task and signal the main thread via the message queue.
The only problem is that if the main thread is terminated (perhaps the user decided to end the program in the middle of a task), it must signal all worker threads to abort before the main thread can end. To achieve this, the main thread simply posts messages for each of its threads onto its own queue. When one of these messages reaches the front of the queue it will simply ignore it. Meanwhile the worker threads will periodically examine the queue to see if there are any messages intended for it and process them accordingly, removing them from the queue and signalling the message queue when they've completed the abortion. Once all workers have signalled that they have aborted, the main thread can safely terminate.
CGI creates process for each client call where as servlet creates process for the first time and then uses thread for each client.
A thread is a sub process in other words one process can contain multiple threads.
The same metaphor: the difference of a person (thread) and a family (process) A process has at least 1 thread and may have many threads, while 1 thread must live within a process
No.
Basically no difference, except that process can use many threads; thread can use only one.
No, a thread can't create aprocess, because the environment of the thread is a part of a process which created this thread.
No. A thread is a part of a process, but a process can not be part of a thread. Processes are always "at the top."
Execution context within a process is called Thread. Threads run, process does not. Every process starts with one thread.
Process based is much time as comparison as thread based. as well as Thread based application is cost effective. Process based application has its own address space so it take more cost. Alok Gupta. India.
Differences between public administration and political process?
synchornisation is the process where more than one thread can be accessed by accesssing the shared object of the class.By syncornisation we can have the communication between threads.if one thread works then another thread automatically stops
yes, because if process is terminated then its related thread has no work. After completion of process the kernel generates a thread that will cancelled the thread in order to save the time and memory of CPU.