• Post Reply Bookmark Topic Watch Topic
  • New Topic

Process and threads  RSS feed

 
Smita Chopra
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please tell me the answer to this ques. I was asked this ques. in a recent interview.

Ques. Considering notepad/IE or any other thing as process, What will happen if you start notepad or IE 3 times? Where 3 processes are started or 3 threads are started ?

Thanks
 
anshuman roy
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i dont know the answer as they are not related to java threads.. maybe i can suggest u a very good book..
it's oreilly's java threads....

cheers
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually process means a "heavy weight" program context started by the operating system. If you start NotePad three times, each one is a process. You can see three applications and three processes in Task Manager.

Threads are "light weight", meaning it's a lot less work to set one up, manage it and tear it down. A single process can manage multiple threads. A new Java thread may or may not be a new thread in the operating system, depending on the version of the JVM.

Even though threads are much lighter than processes, they're not without cost. Programs that run hundreds or thousands of threaded tasks use thread pooling to reuse them rather than create and destroy them all the time.

Does that help?
 
Smita Chopra
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for helping
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IE always starts in a new process, too. If you just open a new window, though, it runs in the same process. (I think some IE versions have an option to change the latter behaviour.)
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course, this isn't necessarily generalizable to any application. It looks like Firefox is smart enough to start a new thread in the first process rather than creating a second process when you start it again. Basically this is up to the programmer that wrote the program. Most likely Firefox does start a new process that notices one already exists. The new one then probably tells the old one that it should just open a new window. Of course, this is just my guess. I may be way off here. Who knows?

Layne
[ July 02, 2005: Message edited by: Layne Lund ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!