Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a single thread execute to completion

I was asked this question in an interview - not sure if it makes sense.

You have several threads of same priority started and running, how do you make sure that a particular thread among those is run to completion first?

You can't use wait() and sleep() trick on other threads..

EDIT: Modifying the other threads is not allowed.

like image 217
Johnbabu Koppolu Avatar asked Jan 19 '23 07:01

Johnbabu Koppolu


1 Answers

have one thread join() the other

like image 52
ratchet freak Avatar answered Jan 25 '23 00:01

ratchet freak