JavaGian java tutorial and java interview question and answer

JavaGian , Free Online Tutorials, JavaGian provides tutorials and interview questions of all technology like java tutorial, android, java frameworks, javascript, ajax, core java, sql, python, php, c language etc. for beginners and professionals.

Showing posts with label Process. Show all posts
Showing posts with label Process. Show all posts

Difference between process and thread in java

7:39 AM
Process vs Thread: The process can be referred as program in execution whereas thread is part of process. Process has its own address space whereas multiple threads share same address space of process. Each thread has its own stack. Process can have multiple threads but thread is the smallest unit which can execute concurrently with other threads. Process are quite heavyweight and have more overhead whereas thread is light weight and have less overhead. Process do not depend on each other whereas threads are not independent as they share address space. You do not require synchronization in case of process. Threads require synchronization to avoid unexpected scenarios. Processes can communicate to each other using inter-process communication only where as thread can communicate directly as thread share same address space. You can easily create new threads by calling thread’s start method but you need to copy resources of parent process to create a new child pro...

.