PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Revolut

Implement a thread-safe money transfer

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's mastery of concurrent programming and data-integrity principles, focusing on thread safety, atomic state updates, and deadlock avoidance when transferring funds between shared accounts.

  • medium
  • Revolut
  • Coding & Algorithms
  • Software Engineer

Implement a thread-safe money transfer

Company: Revolut

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem: Implement a concurrent-safe transfer function You are given an in-memory store of bank accounts: - Each account has an `accountId` and a `balance` (integer cents). - Multiple threads may call `transfer(fromId, toId, amount)` concurrently. ### Task Implement `transfer(fromId, toId, amount)` such that it is: - **Correct under concurrency** (no lost updates). - **Atomic**: either the money moves from `fromId` to `toId` entirely, or nothing changes. - **Deadlock-free** under concurrent transfers between overlapping accounts. ### Rules - Validate inputs: - `amount > 0` - accounts must exist - reject/return failure on insufficient funds - The total sum of money across all accounts must remain unchanged after any successful transfer. ### Assumptions - Single process / single JVM (no distributed transactions). - You may use locks (e.g., synchronized/ReentrantLock/ReadWriteLock) or other concurrency primitives. ### Deliverable Provide the API design and implementation approach, including how you prevent deadlocks and ensure correctness.

Quick Answer: This question evaluates a candidate's mastery of concurrent programming and data-integrity principles, focusing on thread safety, atomic state updates, and deadlock avoidance when transferring funds between shared accounts.

Related Interview Questions

  • Implement a random fixed-size load balancer - Revolut (medium)
Revolut logo
Revolut
Feb 11, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
5
0

Problem: Implement a concurrent-safe transfer function

You are given an in-memory store of bank accounts:

  • Each account has an accountId and a balance (integer cents).
  • Multiple threads may call transfer(fromId, toId, amount) concurrently.

Task

Implement transfer(fromId, toId, amount) such that it is:

  • Correct under concurrency (no lost updates).
  • Atomic : either the money moves from fromId to toId entirely, or nothing changes.
  • Deadlock-free under concurrent transfers between overlapping accounts.

Rules

  • Validate inputs:
    • amount > 0
    • accounts must exist
    • reject/return failure on insufficient funds
  • The total sum of money across all accounts must remain unchanged after any successful transfer.

Assumptions

  • Single process / single JVM (no distributed transactions).
  • You may use locks (e.g., synchronized/ReentrantLock/ReadWriteLock) or other concurrency primitives.

Deliverable

Provide the API design and implementation approach, including how you prevent deadlocks and ensure correctness.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Revolut•More Software Engineer•Revolut Software Engineer•Revolut Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.