Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Dart (3.13) Module 12

Concurrency with isolates interview questions

Interview questions on concurrency with isolates: short warm-ups, then what each harder question tests, the first step of a good answer and its follow-ups.

8 questions: 3 warm-ups and 5 with model answers · Levels: Fresher to senior

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher to mid

    In what ways does a Dart isolate differ from a thread in Java or C++?

    Answered in the lesson Isolates and Isolate.run for heavy work

  2. Fresher

    Why does marking a CPU-heavy function async not keep an app responsive?

    Answered in the lesson Isolates and Isolate.run for heavy work

  3. Fresher to mid

    What do a SendPort and a ReceivePort each do in a two-isolate program?

    Answered in the lesson Long-lived isolates, SendPort and ReceivePort

Questions with model answers

What each question tests, the first step of a good answer and the follow-ups to expect.

  1. Mid to senior

    A nightly Dart job reads 12 monthly sales files, parses them and merges the totals. It takes 48 minutes in one isolate, and parsing is 75 % of that time. The server has 8 cores. How many isolates would you use, what run time do you expect, and what limits it?

    What it tests
    Applying Amdahl's law to real numbers, knowing what isolates cost in start-up, memory and copies, and checking that a split job still gives the same totals.
    First step
    Separate what can run in parallel, parsing the 12 files, from what cannot, reading the list and merging, and put minutes on both: 36 minutes of parsing and 12 minutes of everything else. Only then choose a number of isolates.
    Follow-ups

    From the lesson Isolates and Isolate.run for heavy work

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.

    Opening the model answers with your pass…

    Model answers open with any MySmartCoPilot pass.

    • Pro pass · 1 week₹79$2.99
    • 30 days₹179$5.99
    • 1 year₹1,699$45

    One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

    It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 4 minutes
  2. Mid to senior

    Your Dart package checks uploaded images inside Isolate.run so that apps stay responsive. A team now builds it for the web with dart compile js, and every check fails with UnsupportedError. Why, and how do you change the package so that native and web users both get a working check?

    What it tests
    Knowing that the web platform has no isolates, choosing between conditional imports, web workers and work split into short steps on the main thread, and keeping one API on every platform.
    First step
    Find where the error comes from: Isolate.run creates a RawReceivePort for its result, which the JavaScript platform does not implement, so the call fails when it runs. The package needs one public function with a native and a web implementation behind it.
    Follow-ups

    From the lesson Isolates and Isolate.run for heavy work

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  3. Mid to senior

    A Dart image service sends resize jobs to four worker isolates, and all replies come back to one ReceivePort in main. Under load, a few customers receive another customer's thumbnail. What is wrong in the protocol, and how do you fix it so that a slow or crashed worker cannot confuse or block callers?

    What it tests
    Matching replies to requests across isolates, request ids with Completers, handling replies that arrive out of order, and failing the requests of a worker that dies.
    First step
    Look at how a reply finds its caller: what in the reply says which request it answers, and what changes under load, when small and large images are resized at the same time.
    Follow-ups

    From the lesson Long-lived isolates, SendPort and ReceivePort

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  4. Fresher to mid

    A Dart command-line tool spawns two worker isolates, prints report done, and then its CI step keeps running until the job's 60-minute limit. How do you find what keeps it alive, and how do you make every run end on time?

    What it tests
    Knowing what keeps a Dart program running, closing ports and stopping workers in order, and a shutdown that cannot hang on a worker that does not answer.
    First step
    List what the main isolate still holds after it prints: open ReceivePorts, timers that repeat, stream listeners and open files. Any one of them can keep a Dart program running after its work is done.
    Follow-ups

    From the lesson Long-lived isolates, SendPort and ReceivePort

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  5. Mid to senior

    A Dart server receives 200 MB video uploads and sends each to a long-lived worker isolate that computes a SHA-256 checksum. Under load, memory use doubles and the main isolate stalls for tens of milliseconds per upload. What causes both, and how should the bytes reach the worker?

    What it tests
    Knowing that SendPort.send copies the whole message, what TransferableTypedData and Isolate.exit change, and when to send a path or a stream of chunks instead of bytes.
    First step
    Measure what one upload costs on the main isolate's side: how long each send takes, and the memory in use before and after it. Those two numbers show whether the bytes are being copied, and where.
    Follow-ups

    From the lesson Long-lived isolates, SendPort and ReceivePort

    Model answer, Pro.

    In the answer:

    • Model answer
    • Follow-up answers
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes

All Dart (3.13) interview questions · The Dart (3.13) track

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.