Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread and Process

 
Tom Chen
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me the detail differences between thread and process?
Thanks
 
Mike Broadbear
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A decent book:
Concurrency, State Models & Java Programs
by Jeff Magee & Jeff Kramer
'Process' can be used to refer to an operating system process, which is a unit of resource allocation both for CPU time and memory in a system. An os process is characterized by:
-a data segment
-a code segment
-multiple stacks, one for each thread
The code for each thread is in the code segment and all threads in a process can access the data segment. A thread can be represented as a path of execution through code.
Basically, a process may contain several threads. I also think some use the terms 'thread' and 'process' interchangeably.
...Mike B.
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to add my humble comment...in the java world, a process is controlled by the native OS, outside of the java VM. You might have several VMs running on a machine, each in its own process, but the VM itself can't control how much processor time that process receives.
A thread is scheduled and time-sliced by the Java VM. It may delegate certain scheduling tasks to the native OS, depending on the actual VM implementation and native OS, but the threads are much more under the control of the VM than an OS process.
Rob
 
Ash sav
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Process is nothing but different program running on computer concurrently e.g. Microsoft word and Microsoft Paint are running on same computer at the same time.
But the thread is nothing but part of the program which run concurrently on the computer e.g formatting and printing word document. The are two tasks would correspond to executing parts of the program concurrently. Each such part define separate path of execution which is called thread.
Ash
Sun certified Java Programmer
 
Ashutosh Roy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Programs that are running concurrently can be termed as Process.
The sequence of execution in a process can be termed as Thread.
Ashu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic