File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Light weight process Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Light weight process" Watch "Light weight process" New topic
Author

Light weight process

Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
I've heard ( or read ) that Threads are lightweight processes. Can any say what does it mean exactly ?


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
A program is a heavyweight process...because a program can remain in xcution for a long duration depending upon the size & complexity of the program.

But a thread is a lightweight process becaues it represents a fragment
of a bigger program and can wrap its xcuition quickly or like a daemon thread start off a new thread and wait..that threads job is done.

Also in OS world, the context-switching is another factor that has to be taken into consideration.Context switching between one program and another
would req few xcution cycles..The lengthier program and if there are more prgms in xcution then more prgms vie for xcution cycles(processor).
but threads in contrast would not need to go thru many context switches unlike the programs.

There are other factors too like-address space,etc.

i hope this does make sense to u.

A program / thread in an OS world is a process

progm- heavyweight (time/resources needed are more)
thread-lightweight (less here since it may be xcuting a part of code even though its part of the same prgm)


[ April 08, 2005: Message edited by: A Kumar ]
M Beck
Ranch Hand

Joined: Jan 14, 2005
Posts: 323
i originally heard it explained, years ago, as simply this: processes are "heavy weight" because starting up a new one takes a long time (on the order of milliseconds or so) - there's a lot of overhead involved. threads have less overhead, so they can be started more quickly (perhaps a fraction of a millisecond).

that might have been an incorrect explanation, however. after all, i saw it in a context of "how can we make starting a process faster in our operating system".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Light weight process