What is the difference between Process and Threads?

Answer Posted / hetal

A process is a running instance of a program to which system allocates resources like CPU time and memory (separate heap, method area etc. which does not overlap with other process running on the system at the same time). In a big application there may be a set of cooperating processes communicating to each other in order to perform the desired functionality. Two processes communicate through well defined inter process communication mechanism, such as pipes, sockets and shared memory, if both processes are running on the same machine.

On the other hand threads exist within a process; every process has at least one thread. A thread is a light weight process that does not require as much resources as a process requires. Threads running inside a process, share the common set of resources among themselves which are allocated to the process (including the memory, the address space). All the threads share the same heap and method area (but individual stacks). All local variables are thread safe in Java because local variables are stored in each thread's own stack and each thread has its own stack created. Because threads share virtual address space, that makes inter thread communication between threads much cheaper than inter process communication between two independent processes

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

To what value is a variable of the string type automatically initialized?

617


How to determine SGA site?

1914


What is the purpose of the notifyall() method?

613


For which statements does it make sense to use a label?

593


what is Activation Instantinator?

1917






How substring() method of string class create memory leaks?

552


How is a java object message delivered to a non-java client?

579


What are various types of class loaders used by jvm?

502


What state does a thread enter when it terminates its processing?

611


What is a class loader?

591


Explain the steps in details to load the server object dynamically?

4549


A user of a web application sees a jsessionid argument in the URL whenever a resource is accessed. What does this mean? a. The form must have the field jsessionid b. URL rewriting is used as the session method c. Cookies are used for managing sessions

1821


How can I scroll through list of pages like the search results in google?

573


Where can I find seam examples and documentation?

571


Which are the different segments of memory?

602