0

During my distributed programming course in Java, my teacher asked this question. He argued that even if it is a commonly used definition it is not totally true.
What are the things that can make a thread to be considered as a heavy-weight process?

Shashwat Kumar
  • 5,159
  • 2
  • 30
  • 66

2 Answers2

0

There is a definite difference between threads and processes - two or more threads share memory space allocated to the process, while the memory space allocated to 2 processes are separate.

What are the things that can make a thread to be considered as a heavy-weight process?

Again, the threads are not the same as processes, so this question still technically is still incorrect.

Mahesh
  • 5,158
  • 2
  • 15
  • 20
-3

heavily/light weight is about how much resources they take and how expensive it is to switch tasks. On Linux a Thread is also treated like a Process with it's own Process Id, however it doesn't use as much resources as you add each one as it shared memory with an existing thread.

A more light weight version of a thread is to use continuations. This can be cheapest with short call stacks as it is an entirely user space implementation.

Threads are more light weight than processes. But...

  • there are even more light weight was of sharing work, in some contexts threads are expensive.
  • it's not really a process (Linux pretends a thread is a process in some ways)
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • Thanks for the answer, if you could argue further that would be great. –  Oct 16 '16 at 14:49
  • @1z10 what would you like to know. It's a pretty complex subject. – Peter Lawrey Oct 16 '16 at 14:55
  • Just if it is something related with the number of threads being created that makes them to be considered heavy-weigh or if it is related to the need of using synchronized blocks or maybe something deeper at the kernel level and the overheads/disadvantages... Thanks in advance. –  Oct 16 '16 at 15:00
  • @1z10 see my updated answer. The number of threads/processes you can have on Linux is the same. You need to use synchronized only if you have multiple threads, you can't use it across multiple processes. – Peter Lawrey Oct 16 '16 at 15:33