Amazon Interview Question
SDE1sCountry: United States
is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
This question is based on thread scheduling. Normally, if you were designing a thread scheduler and had access to the internals, you would change the priority of each thread such that Thread 1 would have the highest priority, Thread 2 would have a lower priority and Thread 3 would have the lowest priority. And if the scheduler dispatched the threads according to the priorities, then T1, T2, T3 would be executed in that order.
However, in most systems, since you can only treat the Thread Scheduler as a black box, you can only use the join() method to control the execution of the threads. One simple way would be to have thread1 call join() and when it finishes, thread2 calls join() and so forth. In essence, calling join() will make the other thread wait. I have implemented my solution in Python below.
My solution:
- prudent_programmer March 05, 2018