Rubrik | Phone | Task scheduler

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2022-04-12Added By Anonymous
Source: Link

Date: 31st March 2022


Round: 1st interview round


Implement two methods in a class, schedule() and waitUntilComplete().

schedule() should enqueue work to be performed and should be non-blocking.

waitUntilComplete() should block the call untill all scheduled work is completed.

Builtin thread safe constructs like Deque, BlockingQueue, etc. can't be used. Implement it using locks, etc ensuring thread safety.

Comments