Google·Software Engineer·Onsite - System Design / Architecture
- Design and implement an AsyncFuture<T> class from scratch in Java, including the completion state machine, thread-safe callback registration, and composition operators like thenApply, thenCompose, and thenCombine. You cannot use CompletableFuture.
- What clarifying questions would you ask before diving into implementing an async future and a parallel array-processing routine on top of it?
- Using your AsyncFuture primitive, implement a parallelProcess routine that splits a large int array into chunks, processes each chunk concurrently, and folds the results into a single future without blocking any pool thread.
- How would you add cancellation and timeouts to your AsyncFuture, and what should happen to a callback that is already mid-execution when cancellation arrives?
- Your callbacks run on whichever thread completes the future. What are the risks of that design, and how would you offload them to a separate executor?
- How would you implement an allOf over N futures using a single atomic counter instead of nesting thenCombine calls pairwise, and what does that do to the critical-path depth?
“This was the main event and it ate most of the session.”