Can a single thread be shared among multiple processes ? If yes how?

2.2k views Asked by At

Each process can have multiple threads , but is it allowed that single thread can be shared among multiple processes ? I have confusion that i am relating this to tightly coupled multiprocessor where memory is shared among multiple processor.

In tightly coupled multiprocessor : memory is shared In loosely coupled multiprocessor : distributed memory

Correct me if i am thinking in wrong direction.

1

There are 1 answers

0
hagrawal7777 On BEST ANSWER

Yes, you are right that accidentally you were thinking in wrong direction.

Now, to start with answer to your confusion, whether it tightly coupled or loosely coupled multi-core or single-core processor etc. etc., in Java a thread will belong to the same process for its life time.

  • The process to which the thread belongs may be parked by the processor to give time to some other process, which would mean that thread is also not active.
  • The thread may be parked by the process to give priority over some other thread. This is exactly what you call as thread priorities.

You can take advantage of multi-core processors using Java's fork/join framework by using all available processors for thread execution. But in this case as well, whether a thread is being executed by one processor or other, thread will stick tightly to the process in which it started it life.