• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Threads vs. processes

 
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was asked..
what is the diff between a thread and a process ?
can anyone help ?
Thanks in advance..
Greetings..
Leena
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A thread shares its memory space with all other threads living inside the same process. On one hand, this makes it easy for threads to interact with each other as they can simply share data (objects). On the other, if a thread crashes badly it can easily take all other threads down with it. Because threads share so many resources with other threads inside the same process, they are relatively lightweight.
A process is isolated as much as possible from other processes by the operating system. In particular processes cannot access each others' memory (although there exists a shared memory facility through which processes can share data). Each process has its owner, security permissions, etc. Processes are considered heavyweight because they are generally expensive to create.
- Peter
[ April 07, 2002: Message edited by: Peter den Haan ]
 
Ranch Hand
Posts: 1170
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another way to look at it is that a process is a set of code and resources. A thread is something which is running at some point in that code using those resources. You can have multiple threads running within a process.
For instance, if you considered a book a process, a thread would be the person reading it. And several different people could read from the same book at the same time.
 
Peter den Haan
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I like your analogy Welcome back, CLG.
- Peter
reply
    Bookmark Topic Watch Topic
  • New Topic