File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes Thread and Process Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Thread and Process" Watch "Thread and Process" New topic
Author

Thread and Process

Natraj Gudla
Ranch Hand

Joined: Feb 09, 2003
Posts: 34
Hi,
I read in my college days that a Thread is a lighter process , is'nt that true?
I had a discussion earlier with a collegue who says , you cannot even call a thread as a lighter process . and i believe that a thread has to start from a process.
I know some things likes the context switch for process is expensive than threads , and threads share a common istruction set with the process that spawned it etc...
can i get clearly the difference in a thread and a process conceptually.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
It depends on the OS but generally starting a new process (say launching an executable from the command line or runtime.exec) is many times more expensive (time & memory) than starting a new thread within a process.
For example, web servers like IIS and J2EE run each request on a thread from a thread pool which is much more efficient than CGI which starts a new process for each request.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Threads and Synchronization forum...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Gayathri Prasad
Ranch Hand

Joined: Jun 25, 2003
Posts: 116
Hi Nataraj,
Thread are certainly light weight when compared to the Processes. This is fundamentally a concept of Operating System and I would suggest you got through the link http://www.cag.lcs.mit.edu/~rinard/osnotes/h2.html
for a better understanding of threads and processes.
ATB,
Gaya3
--------------------------------------------------
Beginning is half done.
 
 
subject: Thread and Process
 
Threads others viewed
Is knowledge of Daemon threads required for 1.4?
thread
Process and threads
Why threads are light weight
What is the difference between process & thread??
IntelliJ Java IDE