What are the differences between processes and threads?



What are the differences between processes and threads?..

Answer / Shalvendra Payal

Processes and threads are both used for executing programs in Java, but they have several key differences:
1. Process: A process is a program in execution along with its allocated resources. It provides an isolated environment to the program, providing better security. On the other hand, threads within a single process share the same memory space and system resources.
2. Thread: A thread is a lightweight sub-task of a process that can run concurrently with other threads in the same process. Each Java application has at least one main thread (the one created by the JVM when the program starts).
3. Synchronization: Processes provide less efficient inter-process communication than threads, as they have to use IPC (Inter-Process Communication) methods like pipes or sockets.
4. Overhead: Creating a new process is more resource-intensive compared to creating a new thread. Threads are lighter and faster to create.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

How do you define a method?

1 Answers  


what is object-oriented programming in java?

1 Answers   Reliance,


Question 6 [9] 6.1 In what situations (in general) would you use a TreeMap? (3) 6.2 In what situations (in general) would you use a HashSet to store a collection of values?

1 Answers  


How to obtain a performance profile of java program

1 Answers  


How many static init can you have?

1 Answers  


could you run the java program without main method?

6 Answers  


What is difference between “==” and equals()?

1 Answers   IBM,


when System.out.println("") is executed what happens in the back ground?

2 Answers  


define polymorphism in java

1 Answers  


What is difference between static and abstract class?

1 Answers  


What is sortedmap interface?

1 Answers  


Can we use both this () and super () in a constructor?

1 Answers  


Categories