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 |
How do you define a method?
what is object-oriented programming in java?
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?
How to obtain a performance profile of java program
How many static init can you have?
could you run the java program without main method?
What is difference between “==” and equals()?
when System.out.println("") is executed what happens in the back ground?
define polymorphism in java
What is difference between static and abstract class?
What is sortedmap interface?
Can we use both this () and super () in a constructor?