+ 1

Steps in thread step by step with dependent result

Hi It is a task to implement the algorithm in 5 steps. These steps are logical for sure. It must be implemented in five different threads and one result is dependent on other results. I tried implementation as below:. Is this correct? What's the use of implementation of threads if result of one is dependent on other? Or am I the one who did not get the implementation/question right . https://sololearn.com/compiler-playground/cN6p7uM3wUDI/?ref=app

19th Feb 2025, 8:39 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
8 Respuestas
19th Feb 2025, 11:28 PM
Bob_Li
Bob_Li - avatar
20th Feb 2025, 1:26 AM
Bob_Li
Bob_Li - avatar
+ 2
Thanks Bob_Li this is much cleaner code. What I am confused about is the need of this implementation . What benefit we will have when all threads can't start until we have result from previous one It is not a sequential execution? If so, why it was asked as thread question. It's overhead (to use thread) when execution is not parallel. Is this correct or we missed something from question?
20th Feb 2025, 3:57 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
maybe think of it as just a proficiency exercise. Not everything we practice on are going to be things we use on actual useful codes...
20th Feb 2025, 4:05 AM
Bob_Li
Bob_Li - avatar
+ 1
Thanks
20th Feb 2025, 6:13 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
Yes ofcourse
20th Feb 2025, 12:55 AM
Navjot Singh
0
Hi
20th Feb 2025, 4:36 PM
Binay Sinha
Binay Sinha - avatar
0
hmm
20th Feb 2025, 10:55 PM
zain duah
zain duah - avatar