Say we have three threads T1, T2 and T3 which
perform sequentially one after another is their any benefit
of using thread over here rather than having a single
process.
Answer Posted / kk
As the execution of the threads are strictly dependent of
finish to start relationship, so using different theads
won't give any benifit except modularity of the
functionalities even if we use multiprocessor system. and
even the process can have multiple functions for the job
that individual thread is doing.
Sumant Kulkarni:
"I really feel, using threads in this situation is wastage
of resources. Using a single process would be the right
choice. This avoids context switching between threads."
Are you sure there will be context switching among threads?
Look, here the threads execution is sequential not
parallel. they are dependent of previous thread to finish
to start.
As the threads T1, T2, T3 are to be executed sequentially,
so first T1 will execute and once the control reach the end
the thread will exit, like that T2 and T3 will exit once
the control reaches the end of the function executed by
that thread. so is there really a need for the OS to do
context switching??? No right.
| Is This Answer Correct ? | 10 Yes | 4 No |
Post New Answer View All Answers
Do threads share file descriptors?
Which thread method is called when a thread starts?
Can python be multithreaded?
Is creating a thread expensive?
Do threads share heap?
What are the two methods to create threads?
Is face threading bad?
Do threads have pids?
Does thread count matter cpu?
Do threads get their own pid?
How many maximum threads can you create?
Can threading damage skin?
Which way of creating thread is better?
What are the disadvantages of threading?
How many threads does an i7 7700k have?